Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding tree view, edit, delete

  • Loading branch information...
commit bf2eaf88ec442eb6ecf1a2c2603255379f36f20e 1 parent d6043dd
= authored
Showing with 677 additions and 40 deletions.
  1. +50 −1 css/custom.css
  2. +18 −6 index.html
  3. +2 −0  js/app.js
  4. +59 −22 js/controllers.js
  5. 0  js/libs/{ → jquery}/jquery-1.7.1.min.js
  6. +49 −0 js/libs/jquery/jquery-ui-1.8.18.custom.min.js
  7. +391 −0 js/libs/jquery/jquery.ui.nestedSortable.js
  8. 0  js/libs/{ → prettify}/lang-apollo.js
  9. 0  js/libs/{ → prettify}/lang-clj.js
  10. 0  js/libs/{ → prettify}/lang-css.js
  11. 0  js/libs/{ → prettify}/lang-go.js
  12. 0  js/libs/{ → prettify}/lang-hs.js
  13. 0  js/libs/{ → prettify}/lang-lisp.js
  14. 0  js/libs/{ → prettify}/lang-lua.js
  15. 0  js/libs/{ → prettify}/lang-ml.js
  16. 0  js/libs/{ → prettify}/lang-n.js
  17. 0  js/libs/{ → prettify}/lang-proto.js
  18. 0  js/libs/{ → prettify}/lang-scala.js
  19. 0  js/libs/{ → prettify}/lang-sql.js
  20. 0  js/libs/{ → prettify}/lang-tex.js
  21. 0  js/libs/{ → prettify}/lang-vb.js
  22. 0  js/libs/{ → prettify}/lang-vhdl.js
  23. 0  js/libs/{ → prettify}/lang-wiki.js
  24. 0  js/libs/{ → prettify}/lang-xq.js
  25. 0  js/libs/{ → prettify}/lang-yaml.js
  26. 0  js/libs/{ → prettify}/prettify.js
  27. +70 −9 js/services.js
  28. +14 −0 js/util.js
  29. +9 −0 js/widgets.js
  30. +13 −0 views/confirmRemove.html
  31. +2 −2 views/elementForm.html
View
51 css/custom.css
@@ -1,4 +1,53 @@
/* CSS Document */
a.icon i{margin:2px 4px 0 0;}
-form{margin:8px 0 10px 0;}
+.formTitle{text-transform:capitalize;}
+
+/* tree */
+.placeholder {
+ background-color: #cfcfcf;
+ height:34px;
+ border-radius: 3px;
+}
+
+.ui-nestedSortable-error {
+ background:#fbe3e4;
+ color:#8a1f11;
+}
+
+ol {
+ margin: 0;
+ padding: 0;
+ padding-left: 30px;
+}
+
+ol.sortable, ol.sortable ol {
+ margin: 0 0 0 25px;
+ padding: 0;
+ list-style-type: none;
+}
+
+ol.sortable {
+ margin: 0;
+}
+
+.sortable li {
+ margin: 0 0 7px 0;
+ padding: 0;
+}
+.sortable li ol li{
+ margin: 7px 0 0 0;
+}
+.sortable li div {
+ border: 1px solid #cccccc;
+ border-radius:3px;
+ padding: 3px 3px 3px 8px;
+ margin: 0;
+ cursor: move;
+ height:28px;
+ line-height:28px;
+ color: #333;
+}
+
+.sortable li div .btn-group{float:right;padding:0;border:0;margin:0;}
View
24 index.html
@@ -2,7 +2,7 @@
<html xmlns:ng="http://angularjs.org" ng:app="formDrop">
<head>
<meta charset="utf-8">
-<title>Test</title>
+<title>FormDrop, Beta</title>
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
@@ -53,16 +53,28 @@
</ul>
<!-- main view -->
<ng:view></ng:view>
- <h2>Output</h2>
- <pre id="code" class="prettyprint linenums" >&lt;?php
+ <div class="row">
+ <div class="span6">
+ <h2>Output</h2>
+ <pre id="code" class="prettyprint linenums" >&lt;?php
//Empty form :(
?&gt;</pre>
-
+ </div>
+ <div class="span6">
+ <h2>Form</h2>
+ <div id="tree">
+
+ </div>
+ <em>Drag to re-arrange form elements</em>
+ </div>
+ </div>
</div>
<script src="js/libs/underscore-min.js" type="text/javascript"></script>
- <script src="js/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
+ <script src="js/libs/jquery/jquery-1.7.1.min.js" type="text/javascript"></script>
+ <script src="js/libs/jquery/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
+ <script src="js/libs/jquery/jquery.ui.nestedSortable.js" type="text/javascript"></script>
<script src="js/libs/bootstrap.min.js" type="text/javascript"></script>
- <script src="js/libs/prettify.js" type="text/javascript"></script>
+ <script src="js/libs/prettify/prettify.js" type="text/javascript"></script>
<script src="js/libs/angular-0.10.7.js" type="text/javascript"></script>
<script src="js/util.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
View
2  js/app.js
@@ -7,6 +7,8 @@ run(['$route', '$window', '$rootScope', function($route, $window, $rootScope) {
// define routes
$route.when("/add/:elementId", {template:'views/elementForm.html', controller:ElementFormCtrl});
+ $route.when("/edit/:elementId", {template:'views/elementForm.html', controller:ElementFormCtrl});
+ $route.when("/remove/:elementId", {template:'views/confirmRemove.html', controller:RemoveFormCtrl});
$route.when("/about", {template:'views/about.html', controller:AboutCtrl});
$route.when("/help", {template:'views/help.html', controller:HelpCtrl});
$route.otherwise({redirectTo: '/'});
View
81 js/controllers.js
@@ -4,42 +4,79 @@
function AppCtrl($route, $scope, $browser, FormService, ElementService) {
//vars
var elements = $scope.elements = ElementService.query({elementId:'elements'}),
- code = $scope.code = "";
+ code = $scope.code = "",
+ tree = $scope.tree = "";
$scope.$on("render",function(){
- code = ""
+ 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>";
}else{
code = "//Empty form :(";
+ tree = "<ul></ul>";
}
$('#code').html("");
- $('#code').text("<?php\n\n" + code + "\n\n?>");
+ $('#code').text("<?php\n\n" + code + "\n\n?>");
+ $('#tree').html(tree)
+ $('#tree ol').nestedSortable({
+ disableNesting: 'no-nest',
+ forcePlaceholderSize: true,
+ handle: 'div',
+ helper: 'clone',
+ items: 'li',
+ opacity: .6,
+ placeholder: 'placeholder',
+ revert: 250,
+ tabSize: 25,
+ tolerance: 'pointer',
+ toleranceElement: '> div',
+ update: function(event, ui) {
+ alert("drag and drop doesn't currently work, but it probably will soon.");
+ }
+ });
prettyPrint();
});
}
/**
+ * Remove Form Controller (Confirmation)
+ */
+function RemoveFormCtrl($scope, $route, $location, $rootScope, FormService){
+ $scope.confirmRemove = function(){
+ FormService.remove($route.current.params.elementId);
+ $rootScope.$broadcast("render");
+ $location.path("/");
+ };
+}
+
+/**
* Element Form Controller
*/
-function ElementFormCtrl(ElementService, FormService, $route, $location, $browser, $scope, $rootScope){
- //set this form up
- var form = $scope.form = {attributes: [],
- element: {},
- label: "",
- children: []}
+function ElementFormCtrl(ElementService, FormService, $routeParams, $location, $browser, $scope, $rootScope){
+ //set this form up
+ var form = $scope.form;
+ 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){
+ form.attributes.push({"attribute":element.attributes[i],"value":element.attributes[i].value});
+ }
+ }
+ });
+ }
- //get the element details
- var element = $scope.element = ElementService.get({elementId: $route.current.params.elementId}, function(element) {
- form.element = element;
- form.label = element.id;
- //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":""});
@@ -50,12 +87,12 @@ function ElementFormCtrl(ElementService, FormService, $route, $location, $browse
}
$scope.save = function(){
- FormService.drupalForm.push(angular.copy(form));
+ FormService.save(form);
$rootScope.$broadcast("render");
$location.path("/");
}
}
-ElementFormCtrl.$inject = ['ElementService','FormService','$route','$location','$browser','$scope','$rootScope'];
+ElementFormCtrl.$inject = ['ElementService','FormService','$routeParams','$location','$browser','$scope','$rootScope'];
//not sure if I'll even need these
function AboutCtrl(){
View
0  js/libs/jquery-1.7.1.min.js → js/libs/jquery/jquery-1.7.1.min.js
File renamed without changes
View
49 js/libs/jquery/jquery-ui-1.8.18.custom.min.js
@@ -0,0 +1,49 @@
+/*!
+ * jQuery UI 1.8.18
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI
+ */(function(a,b){function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;if(!b.href||!g||f.nodeName.toLowerCase()!=="map")return!1;h=a("img[usemap=#"+g+"]")[0];return!!h&&d(h)}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.18",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function h(b,c,d,f){a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)});return c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){if(c===b)return g["inner"+d].call(this);return this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){if(typeof b!="number")return g["outer"+d].call(this,b);return this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!!d&&!!a.element[0].parentNode)for(var e=0;e<d.length;e++)a.options[d[e][0]]&&d[e][1].apply(a.element,c)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var d=c&&c==="left"?"scrollLeft":"scrollTop",e=!1;if(b[d]>0)return!0;b[d]=1,e=b[d]>0,b[d]=0;return e},isOverAxis:function(a,b,c){return a>b&&a<b+c},isOver:function(b,c,d,e,f,g){return a.ui.isOverAxis(b,d,f)&&a.ui.isOverAxis(c,e,g)}}))})(jQuery);/*!
+ * jQuery UI Widget 1.8.18
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Widget
+ */(function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var d=0,e;(e=b[d])!=null;d++)try{a(e).triggerHandler("remove")}catch(f){}c(b)}}else{var d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}});return d.call(a(this),b,c)})}}a.widget=function(b,c,d){var e=b.split(".")[0],f;b=b.split(".")[1],f=e+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][f]=function(c){return!!a.data(c,b)},a[e]=a[e]||{},a[e][b]=function(a,b){arguments.length&&this._createWidget(a,b)};var g=new c;g.options=a.extend(!0,{},g.options),a[e][b].prototype=a.extend(!0,g,{namespace:e,widgetName:b,widgetEventPrefix:a[e][b].prototype.widgetEventPrefix||b,widgetBaseClass:f},d),a.widget.bridge(b,a[e][b])},a.widget.bridge=function(c,d){a.fn[c]=function(e){var f=typeof e=="string",g=Array.prototype.slice.call(arguments,1),h=this;e=!f&&g.length?a.extend.apply(null,[!0,e].concat(g)):e;if(f&&e.charAt(0)==="_")return h;f?this.each(function(){var d=a.data(this,c),f=d&&a.isFunction(d[e])?d[e].apply(d,g):d;if(f!==d&&f!==b){h=f;return!1}}):this.each(function(){var b=a.data(this,c);b?b.option(e||{})._init():a.data(this,c,new d(e,this))});return h}},a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)},a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this),this.element=a(c),this.options=a.extend(!0,{},this.options,this._getCreateOptions(),b);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(c,d){var e=c;if(arguments.length===0)return a.extend({},this.options);if(typeof c=="string"){if(d===b)return this.options[c];e={},e[c]=d}this._setOptions(e);return this},_setOptions:function(b){var c=this;a.each(b,function(a,b){c._setOption(a,b)});return this},_setOption:function(a,b){this.options[a]=b,a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",b);return this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(b,c,d){var e,f,g=this.options[b];d=d||{},c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),c.target=this.element[0],f=c.originalEvent;if(f)for(e in f)e in c||(c[e]=f[e]);this.element.trigger(c,d);return!(a.isFunction(g)&&g.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}})(jQuery);/*!
+ * jQuery UI Mouse 1.8.18
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Mouse
+ *
+ * Depends:
+ * jquery.ui.widget.js
+ */(function(a,b){var c=!1;a(document).mouseup(function(a){c=!1}),a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(a){return b._mouseDown(a)}).bind("click."+this.widgetName,function(c){if(!0===a.data(c.target,b.widgetName+".preventClickEvent")){a.removeData(c.target,b.widgetName+".preventClickEvent"),c.stopImmediatePropagation();return!1}}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(b){if(!c){this._mouseStarted&&this._mouseUp(b),this._mouseDownEvent=b;var d=this,e=b.which==1,f=typeof this.options.cancel=="string"&&b.target.nodeName?a(b.target).closest(this.options.cancel).length:!1;if(!e||f||!this._mouseCapture(b))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){d.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=this._mouseStart(b)!==!1;if(!this._mouseStarted){b.preventDefault();return!0}}!0===a.data(b.target,this.widgetName+".preventClickEvent")&&a.removeData(b.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(a){return d._mouseMove(a)},this._mouseUpDelegate=function(a){return d._mouseUp(a)},a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),b.preventDefault(),c=!0;return!0}},_mouseMove:function(b){if(a.browser.msie&&!(document.documentMode>=9)&&!b.button)return this._mouseUp(b);if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b));return!this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b));return!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);/*
+ * jQuery UI Position 1.8.18
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Position
+ */(function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return g.apply(this,arguments);b=a.extend({},b);var h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" "):[0,0],l,m,n;i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1];return this.each(function(){var c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]!==e){var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0}},top:function(b,c){if(c.at[1]!==e){var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];if(!c||!c.ownerDocument)return null;if(b)return this.each(function(){a.offset.setOffset(this,b)});return h.call(this)}),function(){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&a.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var j in g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",h=a(c).offset(function(a,b){return b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery);/*
+ * jQuery UI Sortable 1.8.18
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Sortables
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.mouse.js
+ * jquery.ui.widget.js
+ */(function(a,b){a.widget("ui.sortable",a.ui.mouse,{widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},destroy:function(){a.Widget.prototype.destroy.call(this),this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var b=this.items.length-1;b>=0;b--)this.items[b].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){b==="disabled"?(this.options[b]=c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(b);var e=null,f=this,g=a(b.target).parents().each(function(){if(a.data(this,d.widgetName+"-item")==f){e=a(this);return!1}});a.data(b.target,d.widgetName+"-item")==f&&(e=a(b.target));if(!e)return!1;if(this.options.handle&&!c){var h=!1;a(this.options.handle,e).find("*").andSelf().each(function(){this==b.target&&(h=!0)});if(!h)return!1}this.currentItem=e,this._removeCurrentsFromItems();return!0},_mouseStart:function(b,c,d){var e=this.options,f=this;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,e.cursorAt&&this._adjustOffsetFromHelper(e.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),e.containment&&this._setContainment(),e.cursor&&(a("body").css("cursor")&&(this._storedCursor=a("body").css("cursor")),a("body").css("cursor",e.cursor)),e.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",e.opacity)),e.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",e.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(var g=this.containers.length-1;g>=0;g--)this.containers[g]._trigger("activate",b,f._uiHash(this));a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b);return!0},_mouseDrag:function(b){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var c=this.options,d=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY<c.scrollSensitivity?this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop+c.scrollSpeed:b.pageY-this.overflowOffset.top<c.scrollSensitivity&&(this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop-c.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-b.pageX<c.scrollSensitivity?this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft+c.scrollSpeed:b.pageX-this.overflowOffset.left<c.scrollSensitivity&&(this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft-c.scrollSpeed)):(b.pageY-a(document).scrollTop()<c.scrollSensitivity?d=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<c.scrollSensitivity&&(d=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed)),b.pageX-a(document).scrollLeft()<c.scrollSensitivity?d=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(d=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))),d!==!1&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(var e=this.items.length-1;e>=0;e--){var f=this.items[e],g=f.item[0],h=this._intersectsWithPointer(f);if(!h)continue;if(g!=this.currentItem[0]&&this.placeholder[h==1?"next":"prev"]()[0]!=g&&!a.ui.contains(this.placeholder[0],g)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],g):!0)){this.direction=h==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(f))this._rearrange(b,f);else break;this._trigger("change",b,this._uiHash());break}}this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs;return!1},_mouseStop:function(b,c){if(!!b){a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b);if(this.options.revert){var d=this,e=d.placeholder.offset();d.reverting=!0,a(this.helper).animate({left:e.left-this.offset.parent.left-d.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:e.top-this.offset.parent.top-d.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1}},cancel:function(){var b=this;if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("deactivate",null,b._uiHash(this)),this.containers[c].containerCache.over&&(this.containers[c]._trigger("out",null,b._uiHash(this)),this.containers[c].containerCache.over=0)}this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem));return this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"=");return d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")});return d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l=d+j>h&&d+j<i&&b+k>f&&b+k<g;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?l:f<b+this.helperProportions.width/2&&c-this.helperProportions.width/2<g&&h<d+this.helperProportions.height/2&&e-this.helperProportions.height/2<i},_intersectsWithPointer:function(b){var c=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top,b.height),d=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left,b.width),e=c&&d,f=this._getDragVerticalDirection(),g=this._getDragHorizontalDirection();if(!e)return!1;return this.floating?g&&g=="right"||f=="down"?2:1:f&&(f=="down"?2:1)},_intersectsWithSides:function(b){var c=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top+b.height/2,b.height),d=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left+b.width/2,b.width),e=this._getDragVerticalDirection(),f=this._getDragHorizontalDirection();return this.floating&&f?f=="right"&&d||f=="left"&&!d:e&&(e=="down"&&c||e=="up"&&!c)},_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;return a!=0&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a),this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c=this,d=[],e=[],f=this._connectWith();if(f&&b)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&e.push([a.isFunction(j.options.items)?j.options.items.call(j.element):a(j.options.items,j.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),j])}}e.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var g=e.length-1;g>=0;g--)e[g][0].each(function(){d.push(this)});return a(d)},_removeCurrentsFromItems:function(){var a=this.currentItem.find(":data("+this.widgetName+"-item)");for(var b=0;b<this.items.length;b++)for(var c=0;c<a.length;c++)a[c]==this.items[b].item[0]&&this.items.splice(b,1)},_refreshItems:function(b){this.items=[],this.containers=[this];var c=this.items,d=this,e=[[a.isFunction(this.options.items)?this.options.items.call(this.element[0],b,{item:this.currentItem}):a(this.options.items,this.element),this]],f=this._connectWith();if(f&&this.ready)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&(e.push([a.isFunction(j.options.items)?j.options.items.call(j.element[0],b,{item:this.currentItem}):a(j.options.items,j.element),j]),this.containers.push(j))}}for(var g=e.length-1;g>=0;g--){var k=e[g][1],l=e[g][0];for(var i=0,m=l.length;i<m;i++){var n=a(l[i]);n.data(this.widgetName+"-item",k),c.push({item:n,instance:k,width:0,height:0,left:0,top:0})}}},refreshPositions:function(b){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var c=this.items.length-1;c>=0;c--){var d=this.items[c];if(d.instance!=this.currentContainer&&this.currentContainer&&d.item[0]!=this.currentItem[0])continue;var e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item;b||(d.width=e.outerWidth(),d.height=e.outerHeight());var f=e.offset();d.left=f.left,d.top=f.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var c=this.containers.length-1;c>=0;c--){var f=this.containers[c].element.offset();this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight()}return this},_createPlaceholder:function(b){var c=b||this,d=c.options;if(!d.placeholder||d.placeholder.constructor==String){var e=d.placeholder;d.placeholder={element:function(){var b=a(document.createElement(c.currentItem[0].nodeName)).addClass(e||c.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];e||(b.style.visibility="hidden");return b},update:function(a,b){if(!e||!!d.forcePlaceholderSize)b.height()||b.height(c.currentItem.innerHeight()-parseInt(c.currentItem.css("paddingTop")||0,10)-parseInt(c.currentItem.css("paddingBottom")||0,10)),b.width()||b.width(c.currentItem.innerWidth()-parseInt(c.currentItem.css("paddingLeft")||0,10)-parseInt(c.currentItem.css("paddingRight")||0,10))}}}c.placeholder=a(d.placeholder.element.call(c.element,c.currentItem)),c.currentItem.after(c.placeholder),d.placeholder.update(c,c.placeholder)},_contactContainers:function(b){var c=null,d=null;for(var e=this.containers.length-1;e>=0;e--){if(a.ui.contains(this.currentItem[0],this.containers[e].element[0]))continue;if(this._intersectsWith(this.containers[e].containerCache)){if(c&&a.ui.contains(this.containers[e].element[0],c.element[0]))continue;c=this.containers[e],d=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0)}if(!!c)if(this.containers.length===1)this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1;else if(this.currentContainer!=this.containers[d]){var f=1e4,g=null,h=this.positionAbs[this.containers[d].floating?"left":"top"];for(var i=this.items.length-1;i>=0;i--){if(!a.ui.contains(this.containers[d].element[0],this.items[i].item[0]))continue;var j=this.items[i][this.containers[d].floating?"left":"top"];Math.abs(j-h)<f&&(f=Math.abs(j-h),g=this.items[i])}if(!g&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[d],g?this._rearrange(b,g,null,!0):this._rearrange(b,null,this.containers[d].element,!0),this._trigger("change",b,this._uiHash()),this.containers[d]._trigger("change",b,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1}},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b,this.currentItem])):c.helper=="clone"?this.currentItem.clone():this.currentItem;d.parents("body").length||a(c.appendTo!="parent"?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]),d[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(d[0].style.width==""||c.forceHelperSize)&&d.width(this.currentItem.width()),(d[0].style.height==""||c.forceHelperSize)&&d.height(this.currentItem.height());return d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)){var c=a(b.containment)[0],d=a(b.containment).offset(),e=a(c).css("overflow")!="hidden";this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(e?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(e?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var f=b.pageX,g=b.pageY;if(this.originalPosition){this.containment&&(b.pageX-this.offset.click.left<this.containment[0]&&(f=this.containment[0]+this.offset.click.left),b.pageY-this.offset.click.top<this.containment[1]&&(g=this.containment[1]+this.offset.click.top),b.pageX-this.offset.click.left>this.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top));if(c.grid){var h=this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1];g=this.containment?h-this.offset.click.top<this.containment[1]||h-this.offset.click.top>this.containment[3]?h-this.offset.click.top<this.containment[1]?h+c.grid[1]:h-c.grid[1]:h:h;var i=this.originalPageX+Math.round((f-this.originalPageX)/c.grid[0])*c.grid[0];f=this.containment?i-this.offset.click.left<this.containment[0]||i-this.offset.click.left>this.containment[2]?i-this.offset.click.left<this.containment[0]?i+c.grid[0]:i-c.grid[0]:i:i}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:d.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_rearrange:function(a,b,c,d){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?b.item[0]:b.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var e=this,f=this.counter;window.setTimeout(function(){f==e.counter&&e.refreshPositions(!d)},0)},_clear:function(b,c){this.reverting=!1;var d=[],e=this;!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var f in this._storedCSS)if(this._storedCSS[f]=="auto"||this._storedCSS[f]=="static")this._storedCSS[f]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!c&&d.push(function(a){this._trigger("receive",a,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!c&&d.push(function(a){this._trigger("update",a,this._uiHash())});if(!a.ui.contains(this.element[0],this.currentItem[0])){c||d.push(function(a){this._trigger("remove",a,this._uiHash())});for(var f=this.containers.length-1;f>=0;f--)a.ui.contains(this.containers[f].element[0],this.currentItem[0])&&!c&&(d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.containers[f])),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.containers[f])))}for(var f=this.containers.length-1;f>=0;f--)c||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over=0);this._storedCursor&&a("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!c){this._trigger("beforeStop",b,this._uiHash());for(var f=0;f<d.length;f++)d[f].call(this,b);this._trigger("stop",b,this._uiHash())}return!1}c||this._trigger("beforeStop",b,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!c){for(var f=0;f<d.length;f++)d[f].call(this,b);this._trigger("stop",b,this._uiHash())}this.fromOutside=!1;return!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){var c=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}}),a.extend(a.ui.sortable,{version:"1.8.18"})})(jQuery);
View
391 js/libs/jquery/jquery.ui.nestedSortable.js
@@ -0,0 +1,391 @@
+/*
+ * jQuery UI Nested Sortable
+ * v 1.3.4 / 28 apr 2011
+ * http://mjsarfatti.com/sandbox/nestedSortable
+ *
+ * Depends:
+ * jquery.ui.sortable.js 1.8+
+ *
+ * License CC BY-SA 3.0
+ * Copyright 2010-2011, Manuele J Sarfatti
+ */
+
+(function($) {
+
+ $.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
+
+ options: {
+ tabSize: 20,
+ disableNesting: 'ui-nestedSortable-no-nesting',
+ errorClass: 'ui-nestedSortable-error',
+ listType: 'ol',
+ maxLevels: 0,
+ revertOnError: 1
+ },
+
+ _create: function() {
+ this.element.data('sortable', this.element.data('nestedSortable'));
+ return $.ui.sortable.prototype._create.apply(this, arguments);
+ },
+
+ destroy: function() {
+ this.element
+ .removeData("nestedSortable")
+ .unbind(".nestedSortable");
+ return $.ui.sortable.prototype.destroy.apply(this, arguments);
+ },
+
+ _mouseDrag: function(event) {
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ if (!this.lastPositionAbs) {
+ this.lastPositionAbs = this.positionAbs;
+ }
+
+ //Do scrolling
+ if(this.options.scroll) {
+ var o = this.options, scrolled = false;
+ if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
+
+ if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
+ else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
+
+ if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
+ else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
+
+ } else {
+
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+
+ }
+
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+ }
+
+ //Regenerate the absolute position used for position checks
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Set the helper position
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+
+ //Rearrange
+ for (var i = this.items.length - 1; i >= 0; i--) {
+
+ //Cache variables and intersection, continue if no intersection
+ var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
+ if (!intersection) continue;
+
+ if(itemElement != this.currentItem[0] //cannot intersect with itself
+ && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
+ && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
+ && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
+ //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
+ ) {
+
+ $(itemElement).mouseenter();
+
+ this.direction = intersection == 1 ? "down" : "up";
+
+ if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
+ $(itemElement).mouseleave();
+ this._rearrange(event, item);
+ } else {
+ break;
+ }
+
+ // Clear emtpy ul's/ol's
+ this._clearEmpty(itemElement);
+
+ this._trigger("change", event, this._uiHash());
+ break;
+ }
+ }
+
+ var parentItem = (this.placeholder[0].parentNode.parentNode
+ && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length)
+ ? $(this.placeholder[0].parentNode.parentNode)
+ : null,
+ level = this._getLevel(this.placeholder),
+ childLevels = this._getChildLevels(this.helper),
+ previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
+
+ if (previousItem != null) {
+ while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
+ if (previousItem[0].previousSibling) {
+ previousItem = $(previousItem[0].previousSibling);
+ } else {
+ previousItem = null;
+ break;
+ }
+ }
+ }
+
+ newList = document.createElement(o.listType);
+
+ this.beyondMaxLevels = 0;
+
+ // If the item is moved to the left, send it to its parent level
+ if (parentItem != null && this.positionAbs.left < parentItem.offset().left) {
+ parentItem.after(this.placeholder[0]);
+ this._clearEmpty(parentItem[0]);
+ this._trigger("change", event, this._uiHash());
+ }
+ // If the item is below another one and is moved to the right, make it a children of it
+ else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
+ this._isAllowed(previousItem, level+childLevels+1);
+ if (!previousItem.children(o.listType).length) {
+ previousItem[0].appendChild(newList);
+ }
+ previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
+ this._trigger("change", event, this._uiHash());
+ }
+ else {
+ this._isAllowed(parentItem, level+childLevels);
+ }
+
+ //Post events to containers
+ this._contactContainers(event);
+
+ //Interconnect with droppables
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ //Call callbacks
+ this._trigger('sort', event, this._uiHash());
+
+ this.lastPositionAbs = this.positionAbs;
+ return false;
+
+ },
+
+ _mouseStop: function(event, noPropagation) {
+
+ // If the item is in a position not allowed, send it back
+ if (this.beyondMaxLevels) {
+
+ this.placeholder.removeClass(this.options.errorClass);
+
+ if (this.options.revertOnError) {
+ if (this.domPosition.prev) {
+ $(this.domPosition.prev).after(this.placeholder);
+ } else {
+ $(this.domPosition.parent).prepend(this.placeholder);
+ }
+ this._trigger("revert", event, this._uiHash());
+ } else {
+ var parent = this.placeholder.parent().closest(this.options.items);
+
+ for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
+ parent = parent.parent().closest(this.options.items);
+ }
+
+ parent.after(this.placeholder);
+ this._trigger("change", event, this._uiHash());
+ }
+
+ }
+
+ // Clean last empty ul/ol
+ for (var i = this.items.length - 1; i >= 0; i--) {
+ var item = this.items[i].item[0];
+ this._clearEmpty(item);
+ }
+
+ $.ui.sortable.prototype._mouseStop.apply(this, arguments);
+
+ },
+
+ serialize: function(o) {
+
+ var items = this._getItemsAsjQuery(o && o.connected),
+ str = []; o = o || {};
+
+ $(items).each(function() {
+ var res = ($(o.item || this).attr(o.attribute || 'id') || '')
+ .match(o.expression || (/(.+)[-=_](.+)/)),
+ pid = ($(o.item || this).parent(o.listType)
+ .parent('li')
+ .attr(o.attribute || 'id') || '')
+ .match(o.expression || (/(.+)[-=_](.+)/));
+
+ if (res) {
+ str.push((o.key || res[1] + '[' + (o.key && o.expression ? res[1] : res[2]) + ']')
+ + '='
+ + (pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root'));
+ }
+ });
+
+ if(!str.length && o.key) {
+ str.push(o.key + '=');
+ }
+
+ return str.join('&');
+
+ },
+
+ toHierarchy: function(o) {
+
+ o = o || {};
+ var sDepth = o.startDepthCount || 0,
+ ret = [];
+
+ $(this.element).children('li').each(function () {
+ var level = _recursiveItems($(this));
+ ret.push(level);
+ });
+
+ return ret;
+
+ function _recursiveItems(li) {
+ var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
+ if (id) {
+ var item = {"id" : id[2]};
+ if ($(li).children(o.listType).children('li').length > 0) {
+ item.children = [];
+ $(li).children(o.listType).children('li').each(function() {
+ var level = _recursiveItems($(this));
+ item.children.push(level);
+ });
+ }
+ return item;
+ }
+ }
+ },
+
+ toArray: function(o) {
+
+ o = o || {};
+ var sDepth = o.startDepthCount || 0,
+ ret = [],
+ left = 2;
+
+ ret.push({
+ "item_id": 'root',
+ "parent_id": 'none',
+ "depth": sDepth,
+ "left": '1',
+ "right": ($('li', this.element).length + 1) * 2
+ });
+
+ $(this.element).children('li').each(function () {
+ left = _recursiveArray(this, sDepth + 1, left);
+ });
+
+ ret = ret.sort(function(a,b){ return (a.left - b.left); });
+
+ return ret;
+
+ function _recursiveArray(item, depth, left) {
+
+ var right = left + 1,
+ id,
+ pid;
+
+ if ($(item).children(o.listType).children('li').length > 0) {
+ depth ++;
+ $(item).children(o.listType).children('li').each(function () {
+ right = _recursiveArray($(this), depth, right);
+ });
+ depth --;
+ }
+
+ id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
+
+ if (depth === sDepth + 1) {
+ pid = 'root';
+ } else {
+ var parentItem = ($(item).parent(o.listType)
+ .parent('li')
+ .attr(o.attribute || 'id'))
+ .match(o.expression || (/(.+)[-=_](.+)/));
+ pid = parentItem[2];
+ }
+
+ if (id) {
+ ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
+ }
+
+ left = right + 1;
+ return left;
+ }
+
+ },
+
+ _clearEmpty: function(item) {
+
+ var emptyList = $(item).children(this.options.listType);
+ if (emptyList.length && !emptyList.children().length) {
+ emptyList.remove();
+ }
+
+ },
+
+ _getLevel: function(item) {
+
+ var level = 1;
+
+ if (this.options.listType) {
+ var list = item.closest(this.options.listType);
+ while (!list.is('.ui-sortable')) {
+ level++;
+ list = list.parent().closest(this.options.listType);
+ }
+ }
+
+ return level;
+ },
+
+ _getChildLevels: function(parent, depth) {
+ var self = this,
+ o = this.options,
+ result = 0;
+ depth = depth || 0;
+
+ $(parent).children(o.listType).children(o.items).each(function (index, child) {
+ result = Math.max(self._getChildLevels(child, depth + 1), result);
+ });
+
+ return depth ? result + 1 : result;
+ },
+
+ _isAllowed: function(parentItem, levels) {
+ var o = this.options;
+ // Are we trying to nest under a no-nest or are we nesting too deep?
+ if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
+ if (o.maxLevels < levels && o.maxLevels != 0) {
+ this.placeholder.addClass(o.errorClass);
+ this.beyondMaxLevels = levels - o.maxLevels;
+ } else {
+ this.placeholder.removeClass(o.errorClass);
+ this.beyondMaxLevels = 0;
+ }
+ } else {
+ this.placeholder.addClass(o.errorClass);
+ if (o.maxLevels < levels && o.maxLevels != 0) {
+ this.beyondMaxLevels = levels - o.maxLevels;
+ } else {
+ this.beyondMaxLevels = 1;
+ }
+ }
+ }
+
+ }));
+
+ $.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
+})(jQuery);
View
0  js/libs/lang-apollo.js → js/libs/prettify/lang-apollo.js
File renamed without changes
View
0  js/libs/lang-clj.js → js/libs/prettify/lang-clj.js
File renamed without changes
View
0  js/libs/lang-css.js → js/libs/prettify/lang-css.js
File renamed without changes
View
0  js/libs/lang-go.js → js/libs/prettify/lang-go.js
File renamed without changes
View
0  js/libs/lang-hs.js → js/libs/prettify/lang-hs.js
File renamed without changes
View
0  js/libs/lang-lisp.js → js/libs/prettify/lang-lisp.js
File renamed without changes
View
0  js/libs/lang-lua.js → js/libs/prettify/lang-lua.js
File renamed without changes
View
0  js/libs/lang-ml.js → js/libs/prettify/lang-ml.js
File renamed without changes
View
0  js/libs/lang-n.js → js/libs/prettify/lang-n.js
File renamed without changes
View
0  js/libs/lang-proto.js → js/libs/prettify/lang-proto.js
File renamed without changes
View
0  js/libs/lang-scala.js → js/libs/prettify/lang-scala.js
File renamed without changes
View
0  js/libs/lang-sql.js → js/libs/prettify/lang-sql.js
File renamed without changes
View
0  js/libs/lang-tex.js → js/libs/prettify/lang-tex.js
File renamed without changes
View
0  js/libs/lang-vb.js → js/libs/prettify/lang-vb.js
File renamed without changes
View
0  js/libs/lang-vhdl.js → js/libs/prettify/lang-vhdl.js
File renamed without changes
View
0  js/libs/lang-wiki.js → js/libs/prettify/lang-wiki.js
File renamed without changes
View
0  js/libs/lang-xq.js → js/libs/prettify/lang-xq.js
File renamed without changes
View
0  js/libs/lang-yaml.js → js/libs/prettify/lang-yaml.js
File renamed without changes
View
0  js/libs/prettify.js → js/libs/prettify/prettify.js
File renamed without changes
View
79 js/services.js
@@ -9,14 +9,75 @@ angular.module('formDrop.services', [], function($provide) {
return res('data/7/attributes.json', {}, {});
}]);
+ /**
+ * if Angular's nextUid() was exposed to the API, we'd use that. But since we probably won't
+ * have enough form elements for an overrun, I think a simple int counter will do
+ */
+ var seed = 0;
+
+ //FormService provider
+ var formServiceProvider = function() {
+ this.$get = ['$rootScope', function ($rootScope) {
+ var drupalForm = [],
+ service = {drupalForm : drupalForm,
+ save : function(formElement){
+ var toSave = findFormElementById(formElement.id, drupalForm);
+ if(toSave){
+ toSave = formElement;
+ }else{
+ drupalForm.push(formElement);
+ }
+ },
+ remove : function(id){
+ removeFormElementById(id, drupalForm);
+ },
+ newForm : function(element){
+ seed++;
+ return {id:seed, element: element, label: element.id, attributes: [], children: []};
+ },
+ getById : function(id){
+ return findFormElementById(id, drupalForm);
+ },};
+ return service;
+ }];
+ }
+
+ /**
+ * attempts to find the item in the tree
+ * returns true if removed
+ * returns fals if not
+ */
+ var removeFormElementById = function(id, form){
+ for(var i = 0; i < form.length; i++){
+ if(form[i].id == id){
+ form.splice(i,1);
+ return true;
+ }
+ if(form[i].children.length) {
+ var child = removeFormElementById(id, form[i].children);
+ if(child) return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * attempts to find the item in the tree
+ */
+ var findFormElementById = function(id, form){
+ for(var i = 0; i < form.length; i++){
+ if(form[i].id == id) return form[i];
+ if(form[i].children.length) {
+ var child = findFormElementById(id, form[i].children);
+ if(child) return child;
+ }
+ }
+ return null;
+ }
+
//provide a service to store/manage the form
- $provide.service('FormService', FormServiceProvider);
+ $provide.service('FormService', formServiceProvider);
+
+
+
});
-
-//FormService provider
-function FormServiceProvider() {
- this.$get = ['$rootScope', function ($rootScope) {
- var service = {drupalForm:[]};
- return service;
- }];
-}
View
14 js/util.js
@@ -7,3 +7,17 @@ function toPHP(value,parents){
php+=");"
return php;
}
+
+
+function toEditList(value){
+ var html = '<li id="item-' + value.id + '"><div><strong>' + value.label + '</strong> : <em>' + value.element.id + '</em>';
+ html += '<div class="btn-group">';
+ html += '<a href="#/edit/' + value.id + '" class="btn" title="Edit"><i class="icon-pencil"></i></a>';
+ html += '<a href="#/remove/' + value.id + '" class="btn" title="Remove"><i class="icon-trash"></i></a>';
+ html += '</div></div>';
+ if(value.children.length){
+ html += "<ol>" + _.map(value.children, function(childVal){return toEditList(childVal);}).join("\n") + "</ol>";
+ }
+ html += "</li>";
+ return html;
+}
View
9 js/widgets.js
@@ -0,0 +1,9 @@
+/*
+eventually it would be nice to have the tree control be an angular widget
+angular.widget('fd:tree', function(compileElement){
+ compileElement.css('display', 'block');
+ var form = compileElement.attr('form');
+ return function(linkElement){
+
+ };
+ });*/
View
13 views/confirmRemove.html
@@ -0,0 +1,13 @@
+<div class="modal">
+ <div class="modal-header">
+ <a class="close" href="#">×</a>
+ <h3>Are you sure?</h3>
+ </div>
+ <div class="modal-body">
+ Removing this form element won't only delete the element, but all of its children as well! Are you sure?
+ </div>
+ <div class="modal-footer">
+ <a href="" class="btn" ng:click="confirmRemove()">Yes, Delete it!</a>
+ <a href="#" class="btn btn-primary">Cancel</a>
+ </div>
+<div>
View
4 views/elementForm.html
@@ -1,7 +1,7 @@
<div class="modal">
<div class="modal-header">
<a class="close" href="#">×</a>
- <h3>New {{element.name}}</h3>
+ <h3 class="formTitle">{{mode}} {{element.name}}</h3>
</div>
<div class="modal-body">
<!-- error messages -->
@@ -31,7 +31,7 @@
</div>
</div>
<div class="control-group" ng:repeat="elmProp in form.attributes">
- <select ng:options = "attribute.name for attribute in element.attributes" ng:model="elmProp.attribute">
+ <select name="elmProp.attribute.name{{$index}}" ng:options = "attribute.name for attribute in element.attributes" ng:model="elmProp.attribute">
</select>
<input type="text" name="elmProp{{$index}}" ng:model="elmProp.value" required/>
<a class="btn btn-danger" href="" ng:click="remove($index)"><i class="icon-trash icon-white"></i></a>
Please sign in to comment.
Something went wrong with that request. Please try again.