From 542ca7a3a2e3a05de27cc6088af394c02e0ab905 Mon Sep 17 00:00:00 2001 From: swap jo Date: Sat, 30 Jun 2012 17:13:59 +0530 Subject: [PATCH] initial commit --- .gitignore | 2 + LICENSE | 8 + Readme.htm | 60 ++++ ajax/table_json.php | 45 +++ ajax/table_list.php | 18 ++ coffee/bool-expr.coffee | 324 ++++++++++++++++++++++ coffee/bool-expr.js | 244 +++++++++++++++++ coffee/core.coffee | 464 +++++++++++++++++++++++++++++++ coffee/core.js | 530 ++++++++++++++++++++++++++++++++++++ coffee/core.panes.coffee | 305 +++++++++++++++++++++ coffee/core.panes.js | 324 ++++++++++++++++++++++ coffee/design.coffee | 97 +++++++ coffee/design.js | 70 +++++ coffee/save.js | 101 +++++++ coffee/sql2diag.js | 411 ++++++++++++++++++++++++++++ coffee/watch.sh | 3 + conn.php | 11 + css/design.css | 313 +++++++++++++++++++++ css/tbl_list_overlay.css | 42 +++ images/icons/cross.png | Bin 0 -> 655 bytes index.php | 303 +++++++++++++++++++++ js/backbone-localstorage.js | 84 ++++++ js/backbone-min.js | 33 +++ js/jquery-ui.js | 275 +++++++++++++++++++ js/jquery.cookie.js | 47 ++++ js/jquery.min.js | 4 + js/jsplumb.js | 1 + js/tbl-selection.js | 58 ++++ js/underscore-min.js | 30 ++ lib.php | 16 ++ table_sel_list.php | 36 +++ 31 files changed, 4259 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Readme.htm create mode 100644 ajax/table_json.php create mode 100644 ajax/table_list.php create mode 100644 coffee/bool-expr.coffee create mode 100644 coffee/bool-expr.js create mode 100644 coffee/core.coffee create mode 100644 coffee/core.js create mode 100644 coffee/core.panes.coffee create mode 100644 coffee/core.panes.js create mode 100644 coffee/design.coffee create mode 100644 coffee/design.js create mode 100644 coffee/save.js create mode 100644 coffee/sql2diag.js create mode 100755 coffee/watch.sh create mode 100644 conn.php create mode 100644 css/design.css create mode 100644 css/tbl_list_overlay.css create mode 100644 images/icons/cross.png create mode 100644 index.php create mode 100644 js/backbone-localstorage.js create mode 100755 js/backbone-min.js create mode 100644 js/jquery-ui.js create mode 100644 js/jquery.cookie.js create mode 100644 js/jquery.min.js create mode 100755 js/jsplumb.js create mode 100644 js/tbl-selection.js create mode 100644 js/underscore-min.js create mode 100644 lib.php create mode 100644 table_sel_list.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd0068f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.komodoproject +.komodotools diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ce90aac --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2012 Swapnil M. Joshi + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Readme.htm b/Readme.htm new file mode 100644 index 0000000..89b2e33 --- /dev/null +++ b/Readme.htm @@ -0,0 +1,60 @@ + + + + Read me + + + +
+ +

Readme

+

+ Web-based Visual Query Designer is a fork of my Academic project for B.Sc IT.
+ This tool is ready to be used for generating simple SELECT queries for MySQL. + +

+ +

+ Please let me know if you find it useful. +

+ + Swapnil Joshi
+ + swapnil [dot] gnu [at] gmail.com +

+ Project homepage: http://sourceforge.net/projects/web-vqd/
+ +

Installation

+

+

+

+ + Web-based Visual Query Designer is an open source software released under the + MIT License . + +
+ + + diff --git a/ajax/table_json.php b/ajax/table_json.php new file mode 100644 index 0000000..e3cc132 --- /dev/null +++ b/ajax/table_json.php @@ -0,0 +1,45 @@ + $table_name, + "ColumnName" => '*', + "IsPrimaryKey" => FALSE + ); +while($row = mysqli_fetch_array($result)){ + + $FieldData[] = array( + "TableName" => $table_name, + "ColumnName" => $row['Field'], + "IsPrimaryKey" => ($row['Key'] == 'PRI'? TRUE:FALSE) + //"Selected" => true + ); + +} + +/* +$finalArray = array( + "TableName"=> $table_name , + "Fields" => $FieldData + + ); + */ + +$finalArray = $FieldData; + +print json_encode($finalArray); + +?> diff --git a/ajax/table_list.php b/ajax/table_list.php new file mode 100644 index 0000000..be94a3a --- /dev/null +++ b/ajax/table_list.php @@ -0,0 +1,18 @@ + + +
+ \ No newline at end of file diff --git a/coffee/bool-expr.coffee b/coffee/bool-expr.coffee new file mode 100644 index 0000000..51986e0 --- /dev/null +++ b/coffee/bool-expr.coffee @@ -0,0 +1,324 @@ +$ -> + + window.BoolExpr = Backbone.Model.extend + defaults: -> + LeftTableField: null #'' # TableField + RightOperand: '' #'' + Operator: Constants.EQUALS + isCompoundExpr: false + deleteOK:false + + set_isCompoundExpr : -> + # return true if RightOperand is of type TableField + @set {isCompoundExpr : (@get('RightOperand') instanceof TableField)},{silent:true} + + toString: -> + #"#{@get('LeftTableField')} #{@get('Operator')} #{@get('RightOperand')} " + + if @get 'isCompoundExpr' + "(#{@get('LeftTableField').toString()} #{@get('Operator')} #{@get('RightOperand').toString()})" + else + #"#{@get('LeftTableField')} #{@get('Operator')} #{@get('RightOperand')} " + op = @get 'Operator' + rightOp = @get 'RightOperand' + #enclose in single quotes if used LIKE or rightOp is a string + #rightOp = "'" + rightOp + "'" if op== Constants.LIKE + if isNaN(rightOp) or op== Constants.LIKE + rightOp = "'" + rightOp + "'" + "(#{@get('LeftTableField')} #{@get('Operator')} #{rightOp})" + + getLeftTableField: -> + @get 'LeftTableField' + + getRightOperand: -> + @get 'RightOperand' + + clear: -> + #@destroy() + #BoolExprs.remove @ + @set deleteOK : true + + isCompound: -> + return @get 'isCompoundExpr' + + setOperator: (newOp) -> + @set Operator : newOp + + addBoolExpr: (boolExpr) -> + ### + Turns self into CompBoolExpr form BoolExpr + LeftTableField = clone + RightOperand = boolExpr + Operator = AND + + ### + + console.log "Inside: addBoolExpr" + + #newLeftTF= @clone() #use BoolExprs.create ? + newM = @toJSON() + newLeftTF = BoolExprs.create { + LeftTableField : newM.LeftTableField + RightOperand: newM.RightOperand + Operator: newM.Operator + isCompoundExpr: newM.isCompoundExpr + + },{ silent:true} + + try + @set { + LeftTableField: newLeftTF + RightOperand: boolExpr + Operator: Constants.AND + }, {silent:true} + + #,{silent:true} + catch error + console.log error + + @set {isCompoundExpr : true},{silent: true} + @trigger() + + + window.BoolExprView = Backbone.View.extend + template: _.template($('#bool-expr-template').html()) + events: + "dragstart ": "setCachedView" + "click .operator": "changeOperator" + #"click .operator": "testHnd" + "blur .right-operand" : "setRightOperand" + "click .delete" : "clearIfLast" + "click .bool.expr.left > .delete" : "clearLeftTableField" + "click .bool.expr.right > .delete" : "clearRightTableField" + + testHnd:-> + console.log "handled" + + setRightOperand:(evt) -> + #set only if current view is NOT of CompBoolExpr + #console.log 'arguments' + #console.log arguments + #if !@model.isCompound() + #if $(@el).closest('.expr') == @el + #handle event only if raised by direct child + #if @.$('.right-operand').get(0) == evt.srcElement + if $(@el).children('.right-operand').get(0) == evt.srcElement + val = @.$('.right-operand').val() + @model.set RightOperand: val + + className: "expr" + initialize: -> + #@model.bind('change:isCompoundExpr', @chgNode, @) + #@model.bind('change', @render_spcl, this) + @model.bind('change', @render, this) + @model.bind('change:isCompoundExpr', @render, this) + #@model.bind('change', @childExprRemoved, this) + #@model.bind('remove', @clear, this) + + @model.bind('destroy', @remove, this) + + @leftView=null + @rightView=null + + #clearBoolExpr: -> + + + + #clear: -> + #if !@model.isCompound() + #@model.clear() + #@remove() + + #childExprRemoved: -> + ##if both are in place NO OP + #return 0 if @model.getLeftTableField() and @model.getRightOperand() + ##not removed one + ##liveExpr = if @model.getLeftTableField then + ##liveExpr if @model.getLeftTableField? + #liveExpr = @model.getLeftTableField() or @model.getRightOperand() + ##if @model.getLeftTableField().get 'deleteOK' + + #@model.set { + #LeftTableField : liveExpr.LeftTableField + #Operator: liveExpr.Operator + #RightOperand: liveExpr.RightOperand + #isCompoundExpr: liveExpr.isCompoundExpr + #},{silent:true} + ##@model.set {isCompoundExpr : false},{silent:true} + #@model.trigger() + + + render: -> + #$(@el).html(@template(@model.toJSON())) + #@model.set_isCompoundExpr() + if(@model.get('isCompoundExpr')) + console.log 'rendering CompBoolExpr...' + console.log @model.toString() + + #@leftView.render() + #@rightView.render() + + #explicitly trigger change to force rendering + @model.get('LeftTableField').trigger('change') + @model.get('RightOperand').trigger('change') + #@renderOperator() + else + $(@el).html(@template(@model.toJSON())) + SQLPaneView.render() + @ + + renderOperator: -> + #renders everything but left and right operand + #$(@el).html(@template(@model.toJSON())) + #@.$('.operator').html(@template(@model.toJSON())) + #@.$('.operator').html(@template(@model.toJSON()) + $(@el).children('.operator').html(@template(@model.toJSON())) + @ + + convertView2CompExpr: -> + #renders + $(@el).html(@template(@model.toJSON())) + #@.$('.operator') + #$(@el).closest('.operator') + $(@el).children('.operator') + .before($(@leftView.el)) #detach from existing DOM parent + .after(@rightView.el) + @renderOperator() + + setCachedView: -> + WhereExprMgr.cachedView= @ + + addBoolExpr:(boolExpr, boolExprView) -> + @bool2compound(boolExpr, boolExprView) + + bool2compound:(boolExpr, boolExprView) -> + ### + cache existing el.html + create new view with this.model + set view.el.html = cache.html + view.el.addClass 'left' + @leftView = view + @rightView = boolExprView + @rightView.addClass 'right' + + ### + @model.addBoolExpr(boolExpr) + #look out if child nodes get deleted + #@model.getLeftTableField.bind 'remove',@childExprRemoved,@ + #@model.getRightOperand.bind 'remove',@childExprRemoved,@ + + #@model.getLeftTableField.bind 'change:deleteOK',@childExprRemoved,@ + #@model.getRightOperand.bind 'change:deleteOK',@childExprRemoved,@ + + @leftView = new BoolExprView( + model: @model.get('LeftTableField') + #className: 'bool expr left' + el: $(@el).clone().addClass('bool expr left') + ) #.render() + #model for the new view will be the new LeftTableField + + $(boolExprView.el).addClass 'bool expr right' + @rightView = boolExprView.render() + @convertView2CompExpr() + #@render() + + changeOperator: (evt)-> + return 0 if $(@el).children('.operator').get(0) != evt.srcElement + #@model.setOperator @.$('.operator').val() + @model.setOperator $(evt.srcElement).val() + + clearLeftTableField: (evt)-> + #return 0 if $(@el).children('.delete').get(0) != evt.srcElement + #@model.set LeftTableField : null + #BoolExprs.remove @model.getLeftTableField() #remove old expr + #@model.getLeftTableField().destroy() + deadExpr = @model.getLeftTableField() + return 0 if deadExpr instanceof TableField + liveExpr = @model.getRightOperand().toJSON() + @model.set { + LeftTableField : liveExpr.LeftTableField + Operator: liveExpr.Operator + RightOperand: liveExpr.RightOperand + #isCompoundExpr: liveExpr.isCompoundExpr + isCompoundExpr:false + } + #,{silent:true} + #@initialize() + #@model.set {isCompoundExpr : false},{silent:true} + #@model.trigger('change') + + + clearRightTableField: (evt)-> + deadExpr = @model.getRightOperand() + return 0 if deadExpr instanceof TableField + liveExpr = @model.getLeftTableField().toJSON() + @model.set { + LeftTableField : liveExpr.LeftTableField + Operator: liveExpr.Operator + RightOperand: liveExpr.RightOperand + #isCompoundExpr: liveExpr.isCompoundExpr + isCompoundExpr:false + } + + clearIfLast: -> + if WhereExprMgr.el.find('.expr').size() == 1 + @resetWhereExpr() + + resetWhereExpr: -> + #BoolExprs.reset() + BoolExprs.each (m)-> + m.destroy() + WhereExprMgr.rootBoolExprView = null + SQLPaneView.render() + + + + + window.BoolExprList = Backbone.Collection.extend + model: BoolExpr + localStorage: new Store("BoolExprs") + initialize: -> + @bind("add",@createView,@) + + createView: (boolExpr)-> + view = new BoolExprView( model: boolExpr ) + WhereExprMgr.addAtRootLevel boolExpr, view + SQLPaneView.render() + + window.BoolExprs = new BoolExprList() + + #manages Where exprs + window.WhereExprMgr = { + + ### + WhereExprMgr: -> + BoolExprs.bind "add" + ### + addNewBoolExpr : (tableFld)-> + console.log tableFld + BoolExprs.create( LeftTableField: tableFld ) + + rootBoolExprView: null #stores the root node + + el: $('#pane-where') + + addAtRootLevel: (boolExpr,view) -> + # sets rootBoolExprView OR Compounds with root + if @rootBoolExprView is null + @el.append(view.render().el) + @rootBoolExprView=view + else + @rootBoolExprView.addBoolExpr(boolExpr,view) + @rootBoolExprView.render() + + } + + ### + WhereExprMgr.addNewBoolExpr TableFields.first() + WhereExprMgr.addNewBoolExpr TableFields.last() + ### + #this must be moved in WhereExprMgr's constructor + #BoolExprs.bind "add", WhereExprMgr.addOne, WhereExprMgr + #BoolExprs.bind "change:LeftTableField", WhereExprMgr.addOne, WhereExprMgr + + #WhereExpr is a view for the root node of BoolExpr diff --git a/coffee/bool-expr.js b/coffee/bool-expr.js new file mode 100644 index 0000000..23b7d8d --- /dev/null +++ b/coffee/bool-expr.js @@ -0,0 +1,244 @@ + +$(function() { + window.BoolExpr = Backbone.Model.extend({ + defaults: function() { + return { + LeftTableField: null, + RightOperand: '', + Operator: Constants.EQUALS, + isCompoundExpr: false, + deleteOK: false + }; + }, + set_isCompoundExpr: function() { + return this.set({ + isCompoundExpr: this.get('RightOperand') instanceof TableField + }, { + silent: true + }); + }, + toString: function() { + var op, rightOp; + if (this.get('isCompoundExpr')) { + return "(" + (this.get('LeftTableField').toString()) + " " + (this.get('Operator')) + " " + (this.get('RightOperand').toString()) + ")"; + } else { + op = this.get('Operator'); + rightOp = this.get('RightOperand'); + if (isNaN(rightOp) || op === Constants.LIKE) rightOp = "'" + rightOp + "'"; + return "(" + (this.get('LeftTableField')) + " " + (this.get('Operator')) + " " + rightOp + ")"; + } + }, + getLeftTableField: function() { + return this.get('LeftTableField'); + }, + getRightOperand: function() { + return this.get('RightOperand'); + }, + clear: function() { + return this.set({ + deleteOK: true + }); + }, + isCompound: function() { + return this.get('isCompoundExpr'); + }, + setOperator: function(newOp) { + return this.set({ + Operator: newOp + }); + }, + addBoolExpr: function(boolExpr) { + /* + Turns self into CompBoolExpr form BoolExpr + LeftTableField = clone + RightOperand = boolExpr + Operator = AND + */ + var newLeftTF, newM; + console.log("Inside: addBoolExpr"); + newM = this.toJSON(); + newLeftTF = BoolExprs.create({ + LeftTableField: newM.LeftTableField, + RightOperand: newM.RightOperand, + Operator: newM.Operator, + isCompoundExpr: newM.isCompoundExpr + }, { + silent: true + }); + try { + this.set({ + LeftTableField: newLeftTF, + RightOperand: boolExpr, + Operator: Constants.AND + }, { + silent: true + }); + } catch (error) { + console.log(error); + } + this.set({ + isCompoundExpr: true + }, { + silent: true + }); + return this.trigger(); + } + }); + window.BoolExprView = Backbone.View.extend({ + template: _.template($('#bool-expr-template').html()), + events: { + "dragstart ": "setCachedView", + "click .operator": "changeOperator", + "blur .right-operand": "setRightOperand", + "click .delete": "clearIfLast", + "click .bool.expr.left > .delete": "clearLeftTableField", + "click .bool.expr.right > .delete": "clearRightTableField" + }, + testHnd: function() { + return console.log("handled"); + }, + setRightOperand: function(evt) { + var val; + if ($(this.el).children('.right-operand').get(0) === evt.srcElement) { + val = this.$('.right-operand').val(); + return this.model.set({ + RightOperand: val + }); + } + }, + className: "expr", + initialize: function() { + this.model.bind('change', this.render, this); + this.model.bind('change:isCompoundExpr', this.render, this); + this.model.bind('destroy', this.remove, this); + this.leftView = null; + return this.rightView = null; + }, + render: function() { + if (this.model.get('isCompoundExpr')) { + console.log('rendering CompBoolExpr...'); + console.log(this.model.toString()); + this.model.get('LeftTableField').trigger('change'); + this.model.get('RightOperand').trigger('change'); + } else { + $(this.el).html(this.template(this.model.toJSON())); + SQLPaneView.render(); + } + return this; + }, + renderOperator: function() { + $(this.el).children('.operator').html(this.template(this.model.toJSON())); + return this; + }, + convertView2CompExpr: function() { + $(this.el).html(this.template(this.model.toJSON())); + $(this.el).children('.operator').before($(this.leftView.el)).after(this.rightView.el); + return this.renderOperator(); + }, + setCachedView: function() { + return WhereExprMgr.cachedView = this; + }, + addBoolExpr: function(boolExpr, boolExprView) { + return this.bool2compound(boolExpr, boolExprView); + }, + bool2compound: function(boolExpr, boolExprView) { + /* + cache existing el.html + create new view with this.model + set view.el.html = cache.html + view.el.addClass 'left' + @leftView = view + @rightView = boolExprView + @rightView.addClass 'right' + */ this.model.addBoolExpr(boolExpr); + this.leftView = new BoolExprView({ + model: this.model.get('LeftTableField'), + el: $(this.el).clone().addClass('bool expr left') + }); + $(boolExprView.el).addClass('bool expr right'); + this.rightView = boolExprView.render(); + return this.convertView2CompExpr(); + }, + changeOperator: function(evt) { + if ($(this.el).children('.operator').get(0) !== evt.srcElement) return 0; + return this.model.setOperator($(evt.srcElement).val()); + }, + clearLeftTableField: function(evt) { + var deadExpr, liveExpr; + deadExpr = this.model.getLeftTableField(); + if (deadExpr instanceof TableField) return 0; + liveExpr = this.model.getRightOperand().toJSON(); + return this.model.set({ + LeftTableField: liveExpr.LeftTableField, + Operator: liveExpr.Operator, + RightOperand: liveExpr.RightOperand, + isCompoundExpr: false + }); + }, + clearRightTableField: function(evt) { + var deadExpr, liveExpr; + deadExpr = this.model.getRightOperand(); + if (deadExpr instanceof TableField) return 0; + liveExpr = this.model.getLeftTableField().toJSON(); + return this.model.set({ + LeftTableField: liveExpr.LeftTableField, + Operator: liveExpr.Operator, + RightOperand: liveExpr.RightOperand, + isCompoundExpr: false + }); + }, + clearIfLast: function() { + if (WhereExprMgr.el.find('.expr').size() === 1) return this.resetWhereExpr(); + }, + resetWhereExpr: function() { + BoolExprs.each(function(m) { + return m.destroy(); + }); + WhereExprMgr.rootBoolExprView = null; + return SQLPaneView.render(); + } + }); + window.BoolExprList = Backbone.Collection.extend({ + model: BoolExpr, + localStorage: new Store("BoolExprs"), + initialize: function() { + return this.bind("add", this.createView, this); + }, + createView: function(boolExpr) { + var view; + view = new BoolExprView({ + model: boolExpr + }); + WhereExprMgr.addAtRootLevel(boolExpr, view); + return SQLPaneView.render(); + } + }); + window.BoolExprs = new BoolExprList(); + return window.WhereExprMgr = { + /* + WhereExprMgr: -> + BoolExprs.bind "add" + */ + addNewBoolExpr: function(tableFld) { + console.log(tableFld); + return BoolExprs.create({ + LeftTableField: tableFld + }); + }, + rootBoolExprView: null, + el: $('#pane-where'), + addAtRootLevel: function(boolExpr, view) { + if (this.rootBoolExprView === null) { + this.el.append(view.render().el); + return this.rootBoolExprView = view; + } else { + this.rootBoolExprView.addBoolExpr(boolExpr, view); + return this.rootBoolExprView.render(); + } + } + }; + /* + WhereExprMgr.addNewBoolExpr TableFields.first() + WhereExprMgr.addNewBoolExpr TableFields.last() + */ +}); diff --git a/coffee/core.coffee b/coffee/core.coffee new file mode 100644 index 0000000..a2567a6 --- /dev/null +++ b/coffee/core.coffee @@ -0,0 +1,464 @@ +### +Web-based Visual Query Designer is an open source software released under the MIT License +### + + + + + + +$ -> + window.Constants = { + EQUALS : '=' + LIKE : 'LIKE' + LESS_THAN : '<' + GREATER_THAN : '>' + LESS_EQUAL : '<=' + GREATER_EQUAL : '>=' + NOT_EQUAL : '<>' + AND : ' AND ' + OR : ' OR ' + } + + + Constants.DIAG_CELL_HEIGHT = 20 + Constants.DIAG_UNIQUE_ID = "diag-table-" + #Models + window.TableField = Backbone.Model.extend + defaults: -> + #TableName: "" ? + ColumnName: "" + Selected: false + Alias: "" + Sort: 'UNSORTED' + SortOrder: 0 + IsPrimaryKey: "" + SelectionOrder:0 + left: 0 + #top: 0 + setJoinLeft: -1 #value is irrelevant. used only for triggering change + setJoinRight: -1 + + chgJoinLeft: -> + @set( setJoinLeft : @get('setJoinLeft')*(-1) ) + + chgJoinRight: -> + @set( setJoinRight : @get('setJoinRight')*(-1) ) + + toggleSelected: -> + if @get("Selected") + @set + SelectionOrder: 0 + Selected: false + else + @set + SelectionOrder: TableFields.nextSelectionOrderNo( @.get('TableName') ) + Selected: true + + setTop: (top) -> + @set top:top + + setSortOrder: (newIdx) -> + #accepts a value and sets only if Sort != UNSORTED + @set {SortOrder: + if @get('Sort')=='UNSORTED' then 0 else newIdx} + + changeTopLeft: (dx, dy) -> + @set top: @get('top')+dy , silent:true + @set left: @get('left')+dx , silent:true + @trigger() + + toggleSort: -> + + if @.get('Sort') == 'UNSORTED' + @.set Sort : 'ASC' + else + @.set Sort : 'UNSORTED' + + toString: ()-> + @get('TableName') + "." + @get("ColumnName") + + + # boolexpr code moved to bool-expr.coffee + + #Collections + window.TableFieldList = Backbone.Collection.extend + model: TableField + localStorage: new Store("TableFields") + + nextSelectionOrderNo: (tableName)-> + myTFs= @getModelsByTableName tableName + lastSelOrder = _.max myTFs , (m) -> m.get('SelectionOrder') + lastSelOrder = lastSelOrder.get 'SelectionOrder' + return lastSelOrder+1 + + getModelsByTableName: (tableName) -> + @filter (m) -> m.get('TableName')== tableName + + getModelByTableCol: (tableName,colName) -> + @find (m) -> m.get('TableName')== tableName and m.get('ColumnName')== colName + + getNextTF_Top: (tableName) -> + myTFs = @getModelsByTableName tableName + lastTFM = _.max myTFs , (m) -> m.get('top') + if lastTFM? + return lastTFM.get('top')+ Constants.DIAG_CELL_HEIGHT + else + return Constants.DIAG_CELL_HEIGHT + + window.TableFields = new TableFieldList() + + #View + window.TableFieldView = Backbone.View.extend + className: 'diag-cell' + template: _.template($('#table-field-template').html()) + events: + "click input": "toggleSelected", + "dragstart .cell-dragger": "setJoinLeftTable", + "drop .cell-dragger": "setJoinRightTable" + "click .orderby ": "toggleSort" + #"click .add-condition ": "addToWhere" + + initialize: -> + @model.bind('change', @render, this) + @model.bind('change:setJoinLeft', @setJoinLeftTable, this) #used in MODIFY mode + @model.bind('change:setJoinRight', @setJoinRightTable, this) #used in MODIFY mode + @model.bind('destroy', @clear, this) #remove view if model is destroyed + + $(@el).draggable + helper: "clone" + cursor: "move" + $(@el).droppable() + #the model of respective Table seen at the top + @options.GroupTable.bind 'change' , @reposition , this + + clear: -> + jsPlumb.detachAllConnections @el + @remove() + + render: -> + $(@el) + .css("top", @model.get("top")) + .css("left", @model.get("left")) + .css("position","absolute" ) + $(@el).html(@template(@model.toJSON())) + @ + + reposition : -> + #console.log 'repositioning' + dx = @options.GroupTable.get('chgX') + dy = @options.GroupTable.get('chgY') + @model.changeTopLeft dx, dy + + opacify: (what) -> + + $(@el).css opacity: if what then 0.5 else 1.0 + + setJoinLeftTable : -> + #console.log 'dragstart' + #@opacify true + vqd.setJoinLeftField @el , @model.get('TableName'), @model.get('ColumnName') + + setJoinRightTable: -> + #console.log 'dragstop' + #@opacify false + vqd.completeJoin @el , @model.get('TableName'), @model.get('ColumnName') + + toggleSelected: -> + @model.toggleSelected() + + toggleSort: -> + @model.toggleSort() + ### + addToWhere: -> + #adds current model to 'where' conditions + WhereExprMgr.addNewBoolExpr @model + ### + + + window.Table = Backbone.Model.extend + defaults: -> + TableName: '' + left:0 + top:0 + chgX:0 + chgY:0 + NoOfFields:0 + + incrFieldCounter: -> + #increase fieldCounter + @set NoOfFields: @get('NoOfFields')+1 + + set_dx_dy:(dx,dy) -> + @set {chgX : dx, chgY : dy} + , silent:true + @ + + changeTopLeft: (dx, dy) -> + @set {top: @get('top')+dy } + , silent:true + @set {left: @get('left')+dx} + , silent:true + @ + + triggerChanges: -> + @change() + + window.TableList = Backbone.Collection.extend + model: Table + localStorage: new Store("Tables") + + initialize: -> + @bind('add',@addOne,this) + + addOne: (table) -> + view = new TableView( model: table ) + $('#design-pane').append(view.render().el) + + if @length > 1 + Joins.create + LeftTable : @getLasttableName() + RightTable : table.get('TableName') + + getModelByTableName: (tableName) -> + @find (m) -> m.get('TableName')== tableName + + + getLasttableName: -> + @last(2)[0].get('TableName') #return last but one element since last element is the new element added + + window.Tables = new TableList() + + + #instead of one big view for all TableFields + #we have TableView(s) working for a group(single Table) + #model : Table + window.TableView = Backbone.View.extend + className: 'diag-cell label' + template: _.template($('#table-label-template').html()) + events: + "dragstop .label": "dragStopped" + "click .close": "removeTable" + + initialize: -> + TableFields.bind('add', @addOne, this) + this.model.bind("change", this.render, this) + + $(@el).draggable + helper: 'clone' + cursor: 'move' + #distance: 20 + + $(@el) + .css("position","absolute" ) + + addOne: (tf) -> + tableName = tf.get('TableName') + if tableName == @model.get('TableName') + @model.incrFieldCounter() + tf.setTop(TableFields.getNextTF_Top(tableName) ) + view =new TableFieldView( model: tf , GroupTable: @model ) + $('#design-pane').append view.render().el + + render: -> + $(@el).css("top", @model.get('top')).css "left", @model.get('left') + $(this.el).html(this.template(this.model.toJSON())) + @ + + dragStopped: (event, ui) -> + #console.log "drag Stopped" + chgTop = ui.position.top - ui.originalPosition.top + chgLeft = ui.position.left - ui.originalPosition.left + @model.set_dx_dy chgLeft , chgTop + @model.changeTopLeft chgLeft , chgTop + @model.triggerChanges() + + jsPlumb.repaintEverything() + + + removeTable: -> + console.log "removing table" + tableName=@model.get('TableName') + + for mTF in TableFields.getModelsByTableName( tableName ) + mTF.destroy() + @model.destroy() + @remove() + Joins.removeJoinByTableName tableName + removeSelection(tableName) + + + window.AddTable= (tableName)-> + #exit if table is already added + if Tables.find( ((item) -> + item.get('TableName') == tableName) + , @) + console.log "Table #{tableName} already added" + return 0 + $.ajax({ + url: 'ajax/table_json.php', + dataType: 'json', + data: { table: tableName }, + #async:false + }).done( (data) -> + SQLPaneView.listenEvents=false + Tables.create TableName: tableName + #add data for one Table + for d in data + #console.time "creating TF" + TableFields.create d + #console.timeEnd "creating TF" + SQLPaneView.listenEvents=true + + + TableFields.trigger() + ) + + SQLPaneView.render() + + window.Join = Backbone.Model.extend + defaults: -> + Type: 'CROSS_JOIN' + SelectionOrder: Joins.nextSelectionOrderNo() + Fields: [] + LeftField:'' + RightField:'' + ### + LeftTable + RightTable + ### + setSelectionOrder: (newIdx) -> + @set {SelectionOrder: + newIdx} + + joinOn : (tblLeft,colLeft,tblRight,colRight,joinType="INNER_JOIN") -> + @set {Type: joinType} , silent:true + + if @get('LeftTable')== tblLeft + @set LeftField : colLeft + @set RightField : colRight + else + @set LeftField : colRight + @set RightField : colLeft + + + window.JoinView = Backbone.View.extend( + initialize: -> + @model.bind "change", @render, this + + render: -> + jsPlumb.repaintEverything() + ) + + window.JoinList = Backbone.Collection.extend + model: Join + localStorage: new Store("Joins") + + initialize: -> + #Tables.bind "remove",@removeJoinByTableName,@ + + nextSelectionOrderNo: -> + return 1 if @models.length is 0 + lastSelOrder = _.max @models , (m) -> m.get('SelectionOrder') + lastSelOrder = lastSelOrder.get 'SelectionOrder' + return lastSelOrder+1 + + comparator: (m) -> + m.get 'SelectionOrder' + + getJoinsByTableName: (tableName) -> + @tableName = tableName + @.filter (item) => + m= item.toJSON() + m.LeftTable == @tableName || m.RightTable==@tableName + + removeJoinByTableName: (tableName) -> + console.log 'removing join' + for i in @getJoinsByTableName tableName + i.destroy() + + + + + window.Joins = new JoinList() + + ### + misc. functions + ### + + window.fetchTableResults = (tableName,qid)-> + #fetches resultset of a table in JSON + window.resultset = null + $.ajax({ + url: 'ajax/table_results.php', + dataType: 'json', + #data: { table: tableName , where: where }, + data: { table: tableName , qid: qid }, + #context: @ + async:false + }).done( (data) -> + window.resultset = data + ) + window.resultset + + window.vqd = { + + getStringForConst: (constant) -> + switch constant + when 'INNER_JOIN' then return ' INNER JOIN ' + setJoinLeftField : (el, tableName, columnName) -> + @leftJoinEl = el + @leftJoinColumn = { TableName: tableName , ColumnName: columnName } + + completeJoin : (el, tableName, columnName) -> + my = @ #this alias + # + return 0 if @leftJoinColumn.TableName == tableName + newJoinHost = Joins.find (m) -> + (m.get('LeftTable') == vqd.leftJoinColumn.TableName and m.get('RightTable') == tableName) or + (m.get('RightTable') == vqd.leftJoinColumn.TableName and m.get('LeftTable') == tableName) + + newJoinHost.joinOn(@leftJoinColumn.TableName, @leftJoinColumn.ColumnName,tableName, columnName) + ConnectTableFields @leftJoinEl, el + } + + ### + Connect + ### + + jsPlumb.connectorClass = "diag-join" + window.ConnectTableFields = (elemStart, elemEnd) -> + connectorPaintStyle = + lineWidth: 5 + #strokeStyle: "#CC8A1A" + strokeStyle: "#7794CE" + + common = + anchor: [ "RightMiddle", "LeftMiddle" ] + isSource: true + endpoint: "Blank" + isTarget: true + + e0 = jsPlumb.addEndpoint(elemStart, common, + connectorStyle: connectorPaintStyle + paintStyle: + fillStyle: "#225588" + radius: 7 + + connector: [ "Flowchart" ] + ) + e1 = jsPlumb.addEndpoint(elemEnd, common, + connectorStyle: connectorPaintStyle + paintStyle: + fillStyle: "#225588" + radius: 7 + ) + jsPlumb.connect + source: e0 + target: e1 + overlays: [ [ "Label", + label: "-" + location: 0.5 + ] ] + + diff --git a/coffee/core.js b/coffee/core.js new file mode 100644 index 0000000..733e4e3 --- /dev/null +++ b/coffee/core.js @@ -0,0 +1,530 @@ +/* +Web-based Visual Query Designer is an open source software released under the MIT License +*/ +$(function() { + window.Constants = { + EQUALS: '=', + LIKE: 'LIKE', + LESS_THAN: '<', + GREATER_THAN: '>', + LESS_EQUAL: '<=', + GREATER_EQUAL: '>=', + NOT_EQUAL: '<>', + AND: ' AND ', + OR: ' OR ' + }; + Constants.DIAG_CELL_HEIGHT = 20; + Constants.DIAG_UNIQUE_ID = "diag-table-"; + window.TableField = Backbone.Model.extend({ + defaults: function() { + return { + ColumnName: "", + Selected: false, + Alias: "", + Sort: 'UNSORTED', + SortOrder: 0, + IsPrimaryKey: "", + SelectionOrder: 0, + left: 0, + setJoinLeft: -1, + setJoinRight: -1 + }; + }, + chgJoinLeft: function() { + return this.set({ + setJoinLeft: this.get('setJoinLeft') * (-1) + }); + }, + chgJoinRight: function() { + return this.set({ + setJoinRight: this.get('setJoinRight') * (-1) + }); + }, + toggleSelected: function() { + if (this.get("Selected")) { + return this.set({ + SelectionOrder: 0, + Selected: false + }); + } else { + return this.set({ + SelectionOrder: TableFields.nextSelectionOrderNo(this.get('TableName')), + Selected: true + }); + } + }, + setTop: function(top) { + return this.set({ + top: top + }); + }, + setSortOrder: function(newIdx) { + return this.set({ + SortOrder: this.get('Sort') === 'UNSORTED' ? 0 : newIdx + }); + }, + changeTopLeft: function(dx, dy) { + this.set({ + top: this.get('top') + dy, + silent: true + }); + this.set({ + left: this.get('left') + dx, + silent: true + }); + return this.trigger(); + }, + toggleSort: function() { + if (this.get('Sort') === 'UNSORTED') { + return this.set({ + Sort: 'ASC' + }); + } else { + return this.set({ + Sort: 'UNSORTED' + }); + } + }, + toString: function() { + return this.get('TableName') + "." + this.get("ColumnName"); + } + }); + window.TableFieldList = Backbone.Collection.extend({ + model: TableField, + localStorage: new Store("TableFields"), + nextSelectionOrderNo: function(tableName) { + var lastSelOrder, myTFs; + myTFs = this.getModelsByTableName(tableName); + lastSelOrder = _.max(myTFs, function(m) { + return m.get('SelectionOrder'); + }); + lastSelOrder = lastSelOrder.get('SelectionOrder'); + return lastSelOrder + 1; + }, + getModelsByTableName: function(tableName) { + return this.filter(function(m) { + return m.get('TableName') === tableName; + }); + }, + getModelByTableCol: function(tableName, colName) { + return this.find(function(m) { + return m.get('TableName') === tableName && m.get('ColumnName') === colName; + }); + }, + getNextTF_Top: function(tableName) { + var lastTFM, myTFs; + myTFs = this.getModelsByTableName(tableName); + lastTFM = _.max(myTFs, function(m) { + return m.get('top'); + }); + if (lastTFM != null) { + return lastTFM.get('top') + Constants.DIAG_CELL_HEIGHT; + } else { + return Constants.DIAG_CELL_HEIGHT; + } + } + }); + window.TableFields = new TableFieldList(); + window.TableFieldView = Backbone.View.extend({ + className: 'diag-cell', + template: _.template($('#table-field-template').html()), + events: { + "click input": "toggleSelected", + "dragstart .cell-dragger": "setJoinLeftTable", + "drop .cell-dragger": "setJoinRightTable", + "click .orderby ": "toggleSort" + }, + initialize: function() { + this.model.bind('change', this.render, this); + this.model.bind('change:setJoinLeft', this.setJoinLeftTable, this); + this.model.bind('change:setJoinRight', this.setJoinRightTable, this); + this.model.bind('destroy', this.clear, this); + $(this.el).draggable({ + helper: "clone", + cursor: "move" + }); + $(this.el).droppable(); + return this.options.GroupTable.bind('change', this.reposition, this); + }, + clear: function() { + jsPlumb.detachAllConnections(this.el); + return this.remove(); + }, + render: function() { + $(this.el).css("top", this.model.get("top")).css("left", this.model.get("left")).css("position", "absolute"); + $(this.el).html(this.template(this.model.toJSON())); + return this; + }, + reposition: function() { + var dx, dy; + dx = this.options.GroupTable.get('chgX'); + dy = this.options.GroupTable.get('chgY'); + return this.model.changeTopLeft(dx, dy); + }, + opacify: function(what) { + return $(this.el).css({ + opacity: what ? 0.5 : 1.0 + }); + }, + setJoinLeftTable: function() { + return vqd.setJoinLeftField(this.el, this.model.get('TableName'), this.model.get('ColumnName')); + }, + setJoinRightTable: function() { + return vqd.completeJoin(this.el, this.model.get('TableName'), this.model.get('ColumnName')); + }, + toggleSelected: function() { + return this.model.toggleSelected(); + }, + toggleSort: function() { + return this.model.toggleSort(); + } + /* + addToWhere: -> + #adds current model to 'where' conditions + WhereExprMgr.addNewBoolExpr @model + */ + }); + window.Table = Backbone.Model.extend({ + defaults: function() { + return { + TableName: '', + left: 0, + top: 0, + chgX: 0, + chgY: 0, + NoOfFields: 0 + }; + }, + incrFieldCounter: function() { + return this.set({ + NoOfFields: this.get('NoOfFields') + 1 + }); + }, + set_dx_dy: function(dx, dy) { + this.set({ + chgX: dx, + chgY: dy + }, { + silent: true + }); + return this; + }, + changeTopLeft: function(dx, dy) { + this.set({ + top: this.get('top') + dy + }, { + silent: true + }); + this.set({ + left: this.get('left') + dx + }, { + silent: true + }); + return this; + }, + triggerChanges: function() { + return this.change(); + } + }); + window.TableList = Backbone.Collection.extend({ + model: Table, + localStorage: new Store("Tables"), + initialize: function() { + return this.bind('add', this.addOne, this); + }, + addOne: function(table) { + var view; + view = new TableView({ + model: table + }); + $('#design-pane').append(view.render().el); + if (this.length > 1) { + return Joins.create({ + LeftTable: this.getLasttableName(), + RightTable: table.get('TableName') + }); + } + }, + getModelByTableName: function(tableName) { + return this.find(function(m) { + return m.get('TableName') === tableName; + }); + }, + getLasttableName: function() { + return this.last(2)[0].get('TableName'); + } + }); + window.Tables = new TableList(); + window.TableView = Backbone.View.extend({ + className: 'diag-cell label', + template: _.template($('#table-label-template').html()), + events: { + "dragstop .label": "dragStopped", + "click .close": "removeTable" + }, + initialize: function() { + TableFields.bind('add', this.addOne, this); + this.model.bind("change", this.render, this); + $(this.el).draggable({ + helper: 'clone', + cursor: 'move' + }); + return $(this.el).css("position", "absolute"); + }, + addOne: function(tf) { + var tableName, view; + tableName = tf.get('TableName'); + if (tableName === this.model.get('TableName')) { + this.model.incrFieldCounter(); + tf.setTop(TableFields.getNextTF_Top(tableName)); + view = new TableFieldView({ + model: tf, + GroupTable: this.model + }); + return $('#design-pane').append(view.render().el); + } + }, + render: function() { + $(this.el).css("top", this.model.get('top')).css("left", this.model.get('left')); + $(this.el).html(this.template(this.model.toJSON())); + return this; + }, + dragStopped: function(event, ui) { + var chgLeft, chgTop; + chgTop = ui.position.top - ui.originalPosition.top; + chgLeft = ui.position.left - ui.originalPosition.left; + this.model.set_dx_dy(chgLeft, chgTop); + this.model.changeTopLeft(chgLeft, chgTop); + this.model.triggerChanges(); + return jsPlumb.repaintEverything(); + }, + removeTable: function() { + var mTF, tableName, _i, _len, _ref; + console.log("removing table"); + tableName = this.model.get('TableName'); + _ref = TableFields.getModelsByTableName(tableName); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + mTF = _ref[_i]; + mTF.destroy(); + } + this.model.destroy(); + this.remove(); + Joins.removeJoinByTableName(tableName); + return removeSelection(tableName); + } + }); + return window.AddTable = function(tableName) { + if (Tables.find((function(item) { + return item.get('TableName') === tableName; + }), this)) { + console.log("Table " + tableName + " already added"); + return 0; + } + $.ajax({ + url: 'ajax/table_json.php', + dataType: 'json', + data: { + table: tableName + } + }).done(function(data) { + var d, _i, _len; + SQLPaneView.listenEvents = false; + Tables.create({ + TableName: tableName + }); + for (_i = 0, _len = data.length; _i < _len; _i++) { + d = data[_i]; + TableFields.create(d); + } + SQLPaneView.listenEvents = true; + return TableFields.trigger(); + }); + return SQLPaneView.render(); + }; +}); + +window.Join = Backbone.Model.extend({ + defaults: function() { + return { + Type: 'CROSS_JOIN', + SelectionOrder: Joins.nextSelectionOrderNo(), + Fields: [], + LeftField: '', + RightField: '' + /* + LeftTable + RightTable + */ + }; + }, + setSelectionOrder: function(newIdx) { + return this.set({ + SelectionOrder: newIdx + }); + }, + joinOn: function(tblLeft, colLeft, tblRight, colRight, joinType) { + if (joinType == null) joinType = "INNER_JOIN"; + this.set({ + Type: joinType + }, { + silent: true + }); + if (this.get('LeftTable') === tblLeft) { + this.set({ + LeftField: colLeft + }); + return this.set({ + RightField: colRight + }); + } else { + this.set({ + LeftField: colRight + }); + return this.set({ + RightField: colLeft + }); + } + } +}); + +window.JoinView = Backbone.View.extend({ + initialize: function() { + return this.model.bind("change", this.render, this); + }, + render: function() { + return jsPlumb.repaintEverything(); + } +}); + +window.JoinList = Backbone.Collection.extend({ + model: Join, + localStorage: new Store("Joins"), + initialize: function() {}, + nextSelectionOrderNo: function() { + var lastSelOrder; + if (this.models.length === 0) return 1; + lastSelOrder = _.max(this.models, function(m) { + return m.get('SelectionOrder'); + }); + lastSelOrder = lastSelOrder.get('SelectionOrder'); + return lastSelOrder + 1; + }, + comparator: function(m) { + return m.get('SelectionOrder'); + }, + getJoinsByTableName: function(tableName) { + var _this = this; + this.tableName = tableName; + return this.filter(function(item) { + var m; + m = item.toJSON(); + return m.LeftTable === _this.tableName || m.RightTable === _this.tableName; + }); + }, + removeJoinByTableName: function(tableName) { + var i, _i, _len, _ref, _results; + console.log('removing join'); + _ref = this.getJoinsByTableName(tableName); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + i = _ref[_i]; + _results.push(i.destroy()); + } + return _results; + } +}); + +window.Joins = new JoinList(); + +/* + misc. functions +*/ + +window.fetchTableResults = function(tableName, qid) { + window.resultset = null; + $.ajax({ + url: 'ajax/table_results.php', + dataType: 'json', + data: { + table: tableName, + qid: qid + }, + async: false + }).done(function(data) { + return window.resultset = data; + }); + return window.resultset; +}; + +window.vqd = { + getStringForConst: function(constant) { + switch (constant) { + case 'INNER_JOIN': + return ' INNER JOIN '; + } + }, + setJoinLeftField: function(el, tableName, columnName) { + this.leftJoinEl = el; + return this.leftJoinColumn = { + TableName: tableName, + ColumnName: columnName + }; + }, + completeJoin: function(el, tableName, columnName) { + var my, newJoinHost; + my = this; + if (this.leftJoinColumn.TableName === tableName) return 0; + newJoinHost = Joins.find(function(m) { + return (m.get('LeftTable') === vqd.leftJoinColumn.TableName && m.get('RightTable') === tableName) || (m.get('RightTable') === vqd.leftJoinColumn.TableName && m.get('LeftTable') === tableName); + }); + newJoinHost.joinOn(this.leftJoinColumn.TableName, this.leftJoinColumn.ColumnName, tableName, columnName); + return ConnectTableFields(this.leftJoinEl, el); + } +}; + +/* + Connect +*/ + +jsPlumb.connectorClass = "diag-join"; + +window.ConnectTableFields = function(elemStart, elemEnd) { + var common, connectorPaintStyle, e0, e1; + connectorPaintStyle = { + lineWidth: 5, + strokeStyle: "#7794CE" + }; + common = { + anchor: ["RightMiddle", "LeftMiddle"], + isSource: true, + endpoint: "Blank", + isTarget: true + }; + e0 = jsPlumb.addEndpoint(elemStart, common, { + connectorStyle: connectorPaintStyle, + paintStyle: { + fillStyle: "#225588", + radius: 7 + }, + connector: ["Flowchart"] + }); + e1 = jsPlumb.addEndpoint(elemEnd, common, { + connectorStyle: connectorPaintStyle, + paintStyle: { + fillStyle: "#225588", + radius: 7 + } + }); + return jsPlumb.connect({ + source: e0, + target: e1, + overlays: [ + [ + "Label", { + label: "-", + location: 0.5 + } + ] + ] + }); +}; diff --git a/coffee/core.panes.coffee b/coffee/core.panes.coffee new file mode 100644 index 0000000..5174d5f --- /dev/null +++ b/coffee/core.panes.coffee @@ -0,0 +1,305 @@ +$ -> + #panes + + ### + SelectItemView + ### + window.SelectItemView = Backbone.View.extend { + + template: _.template($('#paneLi-select-template').html()) + + events: + "blur input" : "setAlias" + "click .delete" : "deselectField" + + initialize: -> + @model.bind('change', @render, this) + @model.bind('change:Selected', @moveToLastInPane, this) + @model.bind('destroy', @remove, this) + SelectPaneView.bind 'evtRearranged' , @setSelfSelectionOrder , this + + + render: -> + $(@el).html(@template(@model.toJSON())) + return this + + deselectField : -> + @model.toggleSelected() + + setSelfSelectionOrder: -> + console.log 'setSelfSelectionOrder' + @model.set {SelectionOrder: $(@el).index()} + + moveToLastInPane: -> + if(@model.get('Selected')== false) + # detach and store in el(?) so that SelectionOrder starts from 1 + return + par = $(@el).parent() + i = $(@el).detach() + $(par).append(i) + + setAlias: -> + console.log('setting alias') + alias = $(@el).find('input').val() + @model.set Alias: alias + } + + + #SelectPaneView + window.SelectPaneView = + new (Backbone.View.extend + + el: $('#pane-select') + events: + "sortstop div" : "SelectionOrder_DOM2model" + + initialize: -> + TableFields.bind('add', @addOne, this) + @el.sortable() + + addOne: (tf) -> + view= new SelectItemView( model: tf ) + @el.append view.render().el + + SelectionOrder_DOM2model: -> + console.log 'SelectionOrder_DOM2model' + @trigger 'evtRearranged' + ) + + window.OrderbyItemView = Backbone.View.extend + className: '' + template: _.template($('#paneLI-orderby-template').html()) + + events: + "change select": "changeSortOrder" + "click .delete" : "removeSort" + + initialize: -> + @model.bind('change', @render, this) + @model.bind('destroy', @remove, this) + OrderbyPaneView.bind 'evtRearranged' , @setSelfSortOrder , this + + render: -> + $(@el).html(@template(@model.toJSON())) + @ + + removeSort : () -> + @model.toggleSort() #sets to UNSORTED + + changeSortOrder: -> + console.log this.$('select').val() + console.log 'changeSortOrder' + @model.set Sort : this.$('select').val() + return + + setSelfSortOrder: -> + console.log 'setSelfSortOrder' + @model.setSortOrder $(@el).index() + + + window.OrderbyPaneView = + new (Backbone.View.extend + el: $('#pane-order-by') + events: + "sortstop div" : "SelectionOrder_DOM2model" + + initialize: -> + TableFields.bind('add', @addOne, this) + @el.sortable() + + addOne: (tf) -> + view= new OrderbyItemView( model: tf ) + @el.append view.render().el + + SelectionOrder_DOM2model: -> + console.log 'SelectionOrder_DOM2model' + @trigger 'evtRearranged' + + ) + + ### + Joins + ### + + window.JoinItemView = Backbone.View.extend + className: '' + template: _.template($('#paneLI-join-template').html()) + events: + "change select": "changeJoinType" + #"click .delete" : "removeItem" + + initialize: -> + @model.bind('change', @render, this) + @model.bind('change:Selected', @moveToLastInPane, this) + @model.bind('destroy', @remove, this) + JoinPaneView.bind 'evtRearranged' , @setSelfSelectionOrder , this + + render: -> + $(@el).html(@template(@model.toJSON())) + @ + + changeJoinType: -> + console.log this.$('select').val() + @model.set Type : this.$('select').val() + + return + + setSelfSelectionOrder: -> + console.log 'setSelfSelectionOrder' + @model.setSelectionOrder $(@el).index() + Joins.sort() + + moveToLastInPane: -> + if(@model.get('Selected')== false) + # detach and store in el(?) so that SelectionOrder starts from 1 + return + par = $(@el).parent() + i = $(@el).detach() + $(par).append(i) + + + window.JoinPaneView = + new (Backbone.View.extend + el: $('#pane-join') + events: + "sortstop div" : "SelectionOrder_DOM2model" + + initialize: -> + Joins.bind('add', @addOne, this) + #@el.sortable handle : '.rearrange' + #@el.sortable() + + addOne: (jf) -> + view= new JoinItemView( model: jf ) + @el.append view.render().el + + SelectionOrder_DOM2model: -> + console.log 'SelectionOrder_DOM2model:Join' + @trigger 'evtRearranged' + ) + + # + # SQL generation + # + window.SQLPaneView = + new ( Backbone.View.extend + ### + template: _.template($('#template').html()) + events: + ### + el: $('.output > pre') + initialize: -> + TableFields.bind('change', @render, this) + TableFields.bind('remove', @render, this) + Joins.bind('change', @render, this) + Joins.bind('reset', @render, this) + Joins.bind('remove', @render, this) + @listenEvents = true + ### + BoolExprs.bind('add', @render, this) + BoolExprs.bind('change', @render, this) + BoolExprs.bind('remove', @render, this) + ### + + render: -> + try + #$(@el).html(@getSQL()) + $(@el).html(@getSQL()) if @listenEvents + + catch error + #console.log error #soln. : trigger change event after all models are fetched + finally + @ + + getFullFieldName : (Alias=true)-> + #ret = "`" + @TableName + "`.`" + @ColumnName + "`" + ret = "" + @TableName + "." + @ColumnName + "" + if Alias + ret += " AS " + @Alias unless @Alias is "" + ret + + getOrderbyPart: -> + switch @Sort + when 'ASC' then str= '' + when 'DESC' then str= 'DESC' #the text assigned to str is of SQL syntax + else str='' #UNSORTED + str + + getJoinPart: -> + joinCnt = Joins.length + + #return just the table name if only single table is added + if joinCnt == 0 + return TableFields.first().get('TableName') + + + ret='' + ret += Array( joinCnt + 1 ).join '(' #opening brackets for all joins + ret += @toJoinString.call(Joins.first().toJSON() ,true) + for jfm in Joins.toJSON()[1..joinCnt ] + ret += @toJoinString.call(jfm) + + return ret + + toJoinString : (isFirst=false) -> + getJoinName = (constName) -> + switch constName + when 'INNER_JOIN' then return ' INNER JOIN ' + when 'CROSS_JOIN' then return ' CROSS JOIN ' + when 'LEFT_OUTER' then return ' LEFT OUTER JOIN ' + when 'RIGHT_OUTER' then return ' RIGHT OUTER JOIN ' + + + #ret = "#{ if isFirst then @LeftTable else '\r\n\t\t' } #{@Type} #{@RightTable} " + ret = "#{ if isFirst then @LeftTable else '\r\n\t\t' } #{getJoinName( @Type) } #{@RightTable} " + if @Type != 'CROSS_JOIN' + #ret += " ON " + (" #{@LeftTable}.#{col[0]} = #{@RightTable}.#{col[1]}" for col in @Fields ).join(' AND ') + ret += " ON " + (" #{@LeftTable}.#{@LeftField} = #{@RightTable}.#{@RightField}" ) + + return ret + ")" + + + getWherePart: -> + #"CustName LIKE 'Prof%'" + #"1=1" + + #if WhereExprMgr.rootBoolExprView + # WhereExprMgr.rootBoolExprView.model.toString() + #else + # "" + $('#pane-where textarea').val() + + + getSQL: -> + + #Select part + selectedFields = _.sortBy ( m for m in TableFields.toJSON() when m.Selected ) , + (i) -> i.SelectionOrder + selectPart = ( @getFullFieldName.apply(f) for f in selectedFields ).join(", ") + + #join + joinPart = @getJoinPart() + + #where + wherePart = @getWherePart() + #order by + orderbyFields = _.sortBy ( m for m in TableFields.toJSON() when m.Sort != 'UNSORTED' ) , + (i) -> i.SortOrder + orderbyPart = ( @getFullFieldName.call(f,false) + ' ' + @getOrderbyPart.apply(f) for f in orderbyFields ).join(", ") + + ret = "SELECT \n\t#{selectPart} \n" + ret +="FROM \n\t#{joinPart} \n" + if wherePart != "" + ret +="WHERE \n\t#{wherePart} \n" + if orderbyPart != "" + ret +="ORDER BY \n\t#{orderbyPart}" + else + ret += "\n\n" + + return ret + + ) + + _.extend(SelectPaneView, Backbone.Events) + _.extend(OrderbyPaneView, Backbone.Events) + _.extend(JoinPaneView, Backbone.Events) diff --git a/coffee/core.panes.js b/coffee/core.panes.js new file mode 100644 index 0000000..46e9535 --- /dev/null +++ b/coffee/core.panes.js @@ -0,0 +1,324 @@ + +$(function() { + /* + SelectItemView + */ window.SelectItemView = Backbone.View.extend({ + template: _.template($('#paneLi-select-template').html()), + events: { + "blur input": "setAlias", + "click .delete": "deselectField" + }, + initialize: function() { + this.model.bind('change', this.render, this); + this.model.bind('change:Selected', this.moveToLastInPane, this); + this.model.bind('destroy', this.remove, this); + return SelectPaneView.bind('evtRearranged', this.setSelfSelectionOrder, this); + }, + render: function() { + $(this.el).html(this.template(this.model.toJSON())); + return this; + }, + deselectField: function() { + return this.model.toggleSelected(); + }, + setSelfSelectionOrder: function() { + console.log('setSelfSelectionOrder'); + return this.model.set({ + SelectionOrder: $(this.el).index() + }); + }, + moveToLastInPane: function() { + var i, par; + if (this.model.get('Selected') === false) return; + par = $(this.el).parent(); + i = $(this.el).detach(); + return $(par).append(i); + }, + setAlias: function() { + var alias; + console.log('setting alias'); + alias = $(this.el).find('input').val(); + return this.model.set({ + Alias: alias + }); + } + }); + window.SelectPaneView = new (Backbone.View.extend({ + el: $('#pane-select'), + events: { + "sortstop div": "SelectionOrder_DOM2model" + }, + initialize: function() { + TableFields.bind('add', this.addOne, this); + return this.el.sortable(); + }, + addOne: function(tf) { + var view; + view = new SelectItemView({ + model: tf + }); + return this.el.append(view.render().el); + }, + SelectionOrder_DOM2model: function() { + console.log('SelectionOrder_DOM2model'); + return this.trigger('evtRearranged'); + } + })); + window.OrderbyItemView = Backbone.View.extend({ + className: '', + template: _.template($('#paneLI-orderby-template').html()), + events: { + "change select": "changeSortOrder", + "click .delete": "removeSort" + }, + initialize: function() { + this.model.bind('change', this.render, this); + this.model.bind('destroy', this.remove, this); + return OrderbyPaneView.bind('evtRearranged', this.setSelfSortOrder, this); + }, + render: function() { + $(this.el).html(this.template(this.model.toJSON())); + return this; + }, + removeSort: function() { + return this.model.toggleSort(); + }, + changeSortOrder: function() { + console.log(this.$('select').val()); + console.log('changeSortOrder'); + this.model.set({ + Sort: this.$('select').val() + }); + }, + setSelfSortOrder: function() { + console.log('setSelfSortOrder'); + return this.model.setSortOrder($(this.el).index()); + } + }); + window.OrderbyPaneView = new (Backbone.View.extend({ + el: $('#pane-order-by'), + events: { + "sortstop div": "SelectionOrder_DOM2model" + }, + initialize: function() { + TableFields.bind('add', this.addOne, this); + return this.el.sortable(); + }, + addOne: function(tf) { + var view; + view = new OrderbyItemView({ + model: tf + }); + return this.el.append(view.render().el); + }, + SelectionOrder_DOM2model: function() { + console.log('SelectionOrder_DOM2model'); + return this.trigger('evtRearranged'); + } + })); + /* + Joins + */ + window.JoinItemView = Backbone.View.extend({ + className: '', + template: _.template($('#paneLI-join-template').html()), + events: { + "change select": "changeJoinType" + }, + initialize: function() { + this.model.bind('change', this.render, this); + this.model.bind('change:Selected', this.moveToLastInPane, this); + this.model.bind('destroy', this.remove, this); + return JoinPaneView.bind('evtRearranged', this.setSelfSelectionOrder, this); + }, + render: function() { + $(this.el).html(this.template(this.model.toJSON())); + return this; + }, + changeJoinType: function() { + console.log(this.$('select').val()); + this.model.set({ + Type: this.$('select').val() + }); + }, + setSelfSelectionOrder: function() { + console.log('setSelfSelectionOrder'); + this.model.setSelectionOrder($(this.el).index()); + return Joins.sort(); + }, + moveToLastInPane: function() { + var i, par; + if (this.model.get('Selected') === false) return; + par = $(this.el).parent(); + i = $(this.el).detach(); + return $(par).append(i); + } + }); + window.JoinPaneView = new (Backbone.View.extend({ + el: $('#pane-join'), + events: { + "sortstop div": "SelectionOrder_DOM2model" + }, + initialize: function() { + return Joins.bind('add', this.addOne, this); + }, + addOne: function(jf) { + var view; + view = new JoinItemView({ + model: jf + }); + return this.el.append(view.render().el); + }, + SelectionOrder_DOM2model: function() { + console.log('SelectionOrder_DOM2model:Join'); + return this.trigger('evtRearranged'); + } + })); + window.SQLPaneView = new (Backbone.View.extend({ + /* + template: _.template($('#template').html()) + events: + */ + el: $('.output > pre'), + initialize: function() { + TableFields.bind('change', this.render, this); + TableFields.bind('remove', this.render, this); + Joins.bind('change', this.render, this); + Joins.bind('reset', this.render, this); + Joins.bind('remove', this.render, this); + return this.listenEvents = true; + /* + BoolExprs.bind('add', @render, this) + BoolExprs.bind('change', @render, this) + BoolExprs.bind('remove', @render, this) + */ + }, + render: function() { + try { + if (this.listenEvents) return $(this.el).html(this.getSQL()); + } catch (error) { + + } finally { + this; + } + }, + getFullFieldName: function(Alias) { + var ret; + if (Alias == null) Alias = true; + ret = "" + this.TableName + "." + this.ColumnName + ""; + if (Alias) if (this.Alias !== "") ret += " AS " + this.Alias; + return ret; + }, + getOrderbyPart: function() { + var str; + switch (this.Sort) { + case 'ASC': + str = ''; + break; + case 'DESC': + str = 'DESC'; + break; + default: + str = ''; + } + return str; + }, + getJoinPart: function() { + var jfm, joinCnt, ret, _i, _len, _ref; + joinCnt = Joins.length; + if (joinCnt === 0) return TableFields.first().get('TableName'); + ret = ''; + ret += Array(joinCnt + 1).join('('); + ret += this.toJoinString.call(Joins.first().toJSON(), true); + _ref = Joins.toJSON().slice(1, joinCnt + 1 || 9e9); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + jfm = _ref[_i]; + ret += this.toJoinString.call(jfm); + } + return ret; + }, + toJoinString: function(isFirst) { + var getJoinName, ret; + if (isFirst == null) isFirst = false; + getJoinName = function(constName) { + switch (constName) { + case 'INNER_JOIN': + return ' INNER JOIN '; + case 'CROSS_JOIN': + return ' CROSS JOIN '; + case 'LEFT_OUTER': + return ' LEFT OUTER JOIN '; + case 'RIGHT_OUTER': + return ' RIGHT OUTER JOIN '; + } + }; + ret = "" + (isFirst ? this.LeftTable : '\r\n\t\t') + " " + (getJoinName(this.Type)) + " " + this.RightTable + " "; + if (this.Type !== 'CROSS_JOIN') { + ret += " ON " + (" " + this.LeftTable + "." + this.LeftField + " = " + this.RightTable + "." + this.RightField); + } + return ret + ")"; + }, + getWherePart: function() { + return $('#pane-where textarea').val(); + }, + getSQL: function() { + var f, joinPart, m, orderbyFields, orderbyPart, ret, selectPart, selectedFields, wherePart; + selectedFields = _.sortBy((function() { + var _i, _len, _ref, _results; + _ref = TableFields.toJSON(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + m = _ref[_i]; + if (m.Selected) _results.push(m); + } + return _results; + })(), function(i) { + return i.SelectionOrder; + }); + selectPart = ((function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = selectedFields.length; _i < _len; _i++) { + f = selectedFields[_i]; + _results.push(this.getFullFieldName.apply(f)); + } + return _results; + }).call(this)).join(", "); + joinPart = this.getJoinPart(); + wherePart = this.getWherePart(); + orderbyFields = _.sortBy((function() { + var _i, _len, _ref, _results; + _ref = TableFields.toJSON(); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + m = _ref[_i]; + if (m.Sort !== 'UNSORTED') _results.push(m); + } + return _results; + })(), function(i) { + return i.SortOrder; + }); + orderbyPart = ((function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = orderbyFields.length; _i < _len; _i++) { + f = orderbyFields[_i]; + _results.push(this.getFullFieldName.call(f, false) + ' ' + this.getOrderbyPart.apply(f)); + } + return _results; + }).call(this)).join(", "); + ret = "SELECT \n\t" + selectPart + " \n"; + ret += "FROM \n\t" + joinPart + " \n"; + if (wherePart !== "") ret += "WHERE \n\t" + wherePart + " \n"; + if (orderbyPart !== "") { + ret += "ORDER BY \n\t" + orderbyPart; + } else { + ret += "\n\n"; + } + return ret; + } + })); + _.extend(SelectPaneView, Backbone.Events); + _.extend(OrderbyPaneView, Backbone.Events); + return _.extend(JoinPaneView, Backbone.Events); +}); diff --git a/coffee/design.coffee b/coffee/design.coffee new file mode 100644 index 0000000..5eae9d4 --- /dev/null +++ b/coffee/design.coffee @@ -0,0 +1,97 @@ +$ -> + $('#design-results-btns .btn') + .on "click", (event)-> + if($(this).hasClass('selected')) + #no-op + return + else + #toggle mode + $('#right-pane').toggleClass('design-mode results-mode') + $('#design-results-btns .selected').removeClass('selected') + $(this).addClass('selected') + + if $('#right-pane').hasClass('results-mode') + #fillResultData($('.output pre').html()) + #sqlOut="SELECT * FROM mDC" + #sqlOut = $('.output pre').html() + sqlOut = QueryMaint.getSQL() + fillResultData(sqlOut) + + + + fillResultData = (sql)-> + $.ajax({ + url:"query_results.php" + data:{ sql: sql } + cache:false + + }).done( (html) -> + $('#results-pane').html(html) + ) + + #$('#design-results-btns .results-mode').on('clic)'clic + + #set design-mode as default + $('#design-results-btns .design-mode').trigger('click') + + $('#btn-save') + .on "click", (event)-> + #alert('save clicked') + QueryMaint.save() + + $('#btn-edit-sql') + .on "click", (event)-> + # toggle output/input mode + console.log 'editing sql...' + curMode = if $('#sql-out').hasClass('output-mode') then 'output' else 'input' + if curMode == 'output' + #hide output + #copy text to input textarea + sql = $('#sql-text-op').text() + $('#sql-text-ip').html(sql) + + #change btn label to Done editing + $(this).html('Done editing') + + else #input + #hide input + #SQLDataRestorer.init(0, newSQL) + newSQL = $('#sql-text-ip').val() + SQLDataRestorer.init(0, newSQL) + #change btn label to Edit SQL + $(this).html('Edit SQL') + + $('#sql-out').toggleClass 'output-mode input-mode' + + $('#pane-where textarea') + .on 'blur', (event)-> + SQLPaneView.render() + + $('select[name=schema]') + .on 'blur', (evt)-> + schema = $(evt.target).val() + #$.cookie 'schema', schema + #$.ajax({ + # url:"ajax/table_list.php" + # data:{ schema: schema } + # cache:false + #}).done( (html) -> + # $('#table-list').html(html) + # bindAddTableEvts() + #) + LoadTableList schema + + window.LoadTableList = (schema)-> + $.cookie 'schema', schema + $.ajax({ + url:"ajax/table_list.php" + data:{ schema: schema } + cache:false + }).done( (html) -> + $('#table-list').html(html) + bindAddTableEvts() + ) + + LoadTableList $('select[name=schema]').val() + + \ No newline at end of file diff --git a/coffee/design.js b/coffee/design.js new file mode 100644 index 0000000..11f7bbb --- /dev/null +++ b/coffee/design.js @@ -0,0 +1,70 @@ + +$(function() { + var fillResultData; + $('#design-results-btns .btn').on("click", function(event) { + var sqlOut; + if ($(this).hasClass('selected')) { + return; + } else { + $('#right-pane').toggleClass('design-mode results-mode'); + $('#design-results-btns .selected').removeClass('selected'); + $(this).addClass('selected'); + } + if ($('#right-pane').hasClass('results-mode')) { + sqlOut = QueryMaint.getSQL(); + return fillResultData(sqlOut); + } + }); + fillResultData = function(sql) { + return $.ajax({ + url: "query_results.php", + data: { + sql: sql + }, + cache: false + }).done(function(html) { + return $('#results-pane').html(html); + }); + }; + $('#design-results-btns .design-mode').trigger('click'); + $('#btn-save').on("click", function(event) { + return QueryMaint.save(); + }); + $('#btn-edit-sql').on("click", function(event) { + var curMode, newSQL, sql; + console.log('editing sql...'); + curMode = $('#sql-out').hasClass('output-mode') ? 'output' : 'input'; + if (curMode === 'output') { + sql = $('#sql-text-op').text(); + $('#sql-text-ip').html(sql); + $(this).html('Done editing'); + } else { + newSQL = $('#sql-text-ip').val(); + SQLDataRestorer.init(0, newSQL); + $(this).html('Edit SQL'); + } + return $('#sql-out').toggleClass('output-mode input-mode'); + }); + $('#pane-where textarea').on('blur', function(event) { + return SQLPaneView.render(); + }); + $('select[name=schema]').on('blur', function(evt) { + var schema; + schema = $(evt.target).val(); + return LoadTableList(schema); + }); + window.LoadTableList = function(schema) { + $.cookie('schema', schema); + return $.ajax({ + url: "ajax/table_list.php", + data: { + schema: schema + }, + cache: false + }).done(function(html) { + $('#table-list').html(html); + return bindAddTableEvts(); + }); + }; + return LoadTableList($('select[name=schema]').val()); +}); diff --git a/coffee/save.js b/coffee/save.js new file mode 100644 index 0000000..97ea5af --- /dev/null +++ b/coffee/save.js @@ -0,0 +1,101 @@ + +$(function() { + var QueryMaintClass; + QueryMaintClass = (function() { + + function QueryMaintClass() {} + + QueryMaintClass.prototype.init = function(qname, qid) { + if (qname == null) qname = ""; + if (qid == null) qid = 0; + this.QueryName = qname; + this.sql = ''; + this.QID = qid; + if (this.QID > 0) return SQLDataRestorer.init(this.QID); + }; + + QueryMaintClass.prototype.setQueryName = function(qname) { + this.qname = qname; + }; + + QueryMaintClass.prototype.getSQL = function() { + return $(SQLPaneView.el).text(); + }; + + QueryMaintClass.prototype.getQueryNameFromUser = function() { + return this.QueryName = prompt("Enter query name"); + }; + + QueryMaintClass.prototype.save = function() { + /* + mQuery + QueryName = this.QueryName + SQLText = this.sql + SchemaName + + dQuery + TableName = TableField.TableName + ColumnName = TableField.ColumnName + OffSetX = left + OffSetY = top + */ + var d, data_dQuery, data_mQuery, _i, _len, _ref; + console.log('saving...'); + while (this.QueryName === '' || !this.QueryName) { + this.getQueryNameFromUser(); + if (this.QueryName === '' || !this.QueryName) alert('invalid query name'); + } + this.sql = this.getSQL(); + data_mQuery = { + QID: this.QID, + QueryName: this.QueryName, + SQLText: this.sql + }; + data_dQuery = []; + _ref = TableFields.toJSON(); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + d = _ref[_i]; + data_dQuery.push({ + TableName: d.TableName, + ColumnName: d.ColumnName, + OffSetX: d.left, + OffSetY: d.top + }); + } + console.log(data_mQuery); + console.log(data_dQuery); + return $.ajax({ + type: "GET", + url: "ajax/save_query.php", + data: { + mQuery: data_mQuery, + dQuery: data_dQuery + }, + dataType: "json", + context: QueryMaint + }).done(function(data) { + /* + msg = $.trim msg + if msg == 'true' + window.save_status = true + window.last_saved_at = new Date() + alert "Saved successfully" + */ console.log(data.query_m); + console.log(data.query_d); + if (this.QID === 0) { + this.QID = data.QID; + $('#QueryName').html(this.QueryName); + } + return alert("Saved successfully"); + }); + /* + if window.save_status + alert "Saved successfully" + */ + }; + + return QueryMaintClass; + + })(); + return window.QueryMaint = new QueryMaintClass(); +}); diff --git a/coffee/sql2diag.js b/coffee/sql2diag.js new file mode 100644 index 0000000..e9b0a6a --- /dev/null +++ b/coffee/sql2diag.js @@ -0,0 +1,411 @@ + +$(function() { + window.JoinDesc = { + 'INNER': 'INNER_JOIN', + 'LEFT': 'LEFT_OUTER', + 'RIGHT': 'RIGHT_OUTER', + 'CROSS': 'CROSS_JOIN' + }; + /* + store SQLText + + fetch JSON data from dQuery + for each table, AddTable + using this data, create TableField and put in TableFields + Models + TableField + Table + Join + BoolExpr + + Update + TableField + OffSet X,Y + Selected + SelectionOrder + SortOrder + + + Table + NoOfFields + TableName + left + top + + Create + Join + LeftField: "DCID" + LeftTable: "mDC" + RightField: "DCID" + RightTable: "dDC" + SelectionOrder: 1 + Type: "INNER_JOIN" + + + + Parse SQL , create Join + + + + parse SQLText + parse SELECT part + update TableFields + parse FROM part + create Join in Joins + parse ORDER BY + update TableFields + parse WHERE part + ? + create boolexpr objects + */ + /* + The role of these objects is very short lived + Used only in modify mode, for restoring the Models and other stuff + */ + window.SQLParser = { + parseSQL: function(sql) { + if (!sql) sql = this.SQLText; + this.SQLDataObject.reset(); + this.SQLText = sql; + this.parseSelectClause(); + this.parseJoinClause(); + this.parseOrderByClause(); + return this.SQLDataObject; + }, + SQLDataObject: { + select: [], + join: [], + orderBy: [], + reset: function() { + this.select = []; + this.join = []; + this.singleTable = ""; + return this.orderBy = []; + } + }, + SQLText: '', + trimKeyWords: function(clause) { + var patt; + if (!clause) return ''; + patt = /(SELECT|FROM|WHERE|ORDER BY|ORDER|BY)/gi; + return $.trim(clause.replace(patt, '')); + }, + getSelectionOrder: function() { + return ++this.curSelectionOrder; + }, + resetSelectionOrder: function() { + return this.curSelectionOrder = 0; + }, + stripAllQuotes: function(str) { + return str.replace(/'/g, ""); + }, + getSelectClause: function() { + var patt, selColsPart, selectPart; + patt = /SELECT.*FROM/i; + selectPart = patt.exec(this.SQLText)[0]; + selColsPart = this.trimKeyWords(selectPart); + return $.trim(selColsPart); + }, + getJoinClause: function() { + var joinPart, patt; + patt = /FROM.*?(WHERE|ORDER)/i; + patt = /FROM.*/i; + joinPart = this.SQLText.match(patt)[0]; + joinPart = joinPart.split(/(WHERE|ORDER)/i)[0]; + return this.trimKeyWords(joinPart); + }, + getOrderByClause: function() { + var patt; + patt = /ORDER BY.*/i; + return this.trimKeyWords((patt.exec(this.SQLText) || [''])[0]); + }, + getWhereClause: function() { + var patt, wherePart; + patt = /WHERE.*/i; + wherePart = (patt.exec(this.SQLText) || [''])[0]; + if (!wherePart) return 0; + wherePart = wherePart.split('ORDER BY')[0]; + return this.trimKeyWords(wherePart); + }, + parseJoinClause: function(joinClause) { + var str; + str = this.getJoinClause(); + if (!str.match(/(JOIN)/i)) { + this.SQLDataObject.singleTable = str; + return; + } + this.resetSelectionOrder(); + return this.parseNestedJoinClause(str); + }, + parseNestedJoinClause: function(joinClause) { + var RightTblField, nestedExpr, oJoin, patt; + joinClause = joinClause.slice(1, (joinClause.length - 1)); + patt = /\(.*\)/gi; + if (joinClause.match(patt)) { + nestedExpr = joinClause.match(patt)[0]; + RightTblField = this.parseNestedJoinClause(nestedExpr); + joinClause = joinClause.replace(patt, RightTblField); + } + /* + oJoin = @parseJoinCondition(joinClause) + @SQLDataObject.join.push oJoin + */ + oJoin = this.parseJoinCondition(joinClause); + oJoin.SelectionOrder = this.getSelectionOrder(); + this.SQLDataObject.join.push(oJoin); + return oJoin.RightTable; + }, + parseJoinCondition: function(joinExpr) { + var arr, joinOnPart, joinType, patt, ret; + joinExpr = joinExpr.replace(/\(|\)/g, ''); + patt = /\S* \= \S*/g; + joinOnPart = joinExpr.match(patt)[0]; + patt = /\w{1,}/g; + arr = joinOnPart.match(patt); + ret = { + LeftField: arr[1], + LeftTable: arr[0], + RightField: arr[3], + RightTable: arr[2] + }; + patt = /(INNER|LEFT|RIGHT|CROSS)/i; + joinType = joinExpr.match(patt)[0]; + ret.Type = window.JoinDesc[joinType]; + return ret; + }, + parseSelectClause: function() { + var arrTblCol, i, selectPart, _i, _len; + selectPart = this.getSelectClause(); + arrTblCol = (function() { + var _i, _len, _ref, _results; + _ref = selectPart.split(','); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + i = _ref[_i]; + _results.push($.trim(i)); + } + return _results; + })(); + arrTblCol = (function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = arrTblCol.length; _i < _len; _i++) { + i = arrTblCol[_i]; + _results.push(this.parseSelectUnit(i)); + } + return _results; + }).call(this); + this.resetSelectionOrder(); + for (_i = 0, _len = arrTblCol.length; _i < _len; _i++) { + i = arrTblCol[_i]; + i.SelectionOrder = this.getSelectionOrder(); + } + return this.SQLDataObject.select = arrTblCol; + }, + parseSelectUnit: function(unit) { + var aliasName, cleanUnit, patt, ret, tableCol; + patt = /\sAS\s/i; + if (!unit.match(patt)) { + return unit.split('.'); + } else { + cleanUnit = this.stripAllQuotes(unit); + aliasName = cleanUnit.match(patt)[0]; + aliasName = cleanUnit.split(' AS ')[1]; + tableCol = cleanUnit.split(' AS ')[0]; + aliasName = aliasName.replace(/'/g, ""); + ret = tableCol.split('.'); + ret.aliasName = aliasName; + return ret; + } + }, + parseOrderByClause: function() { + /* + res = [] + (( j for j in i.split(/\.\s/g) ) for i in arr ) + for i in arr ) + */ + var i; + if (this.getOrderByClause() === "") return; + return this.SQLDataObject.orderBy = (function() { + var _i, _len, _ref, _results; + _ref = this.getOrderByClause().split(','); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + i = _ref[_i]; + _results.push(this.parseOrderByUnit(i)); + } + return _results; + }).call(this); + }, + parseOrderByUnit: function(unit) { + var patt, ret; + unit = $.trim(unit); + ret = {}; + /* + if unit.match(/(DESC)/) + ret.SortType = 'DESC' + else + ret.SortType = 'ASC' + */ + ret.SortType = unit.match(/(DESC)/) ? 'DESC' : 'ASC'; + patt = /\w*\./; + ret.TableName = unit.match(patt)[0].replace('.', ''); + patt = /\.\w*/; + ret.ColumnName = unit.match(patt)[0].replace('.', ''); + return ret; + } + }; + return window.SQLDataRestorer = { + init: function(QID, sql) { + this.QID = QID; + this.mQuery = []; + this.dQuery = []; + if (this.QID > 0) { + this.fetchServerData(); + } else { + this.mQuery.SQLText = sql; + } + this.mQuery.SQLText = this.mQuery.SQLText.replace(/(\r\n|\n|\r)/gm, ""); + SQLParser.parseSQL(this.mQuery.SQLText); + this.sqlData = SQLParser.SQLDataObject; + return this.process(); + }, + fetchServerData: function() { + this.mQuery = null; + this.dQuery = null; + this.mQuery = fetchTableResults('mQuery', this.QID)[0]; + return this.dQuery = fetchTableResults('dQuery', this.QID); + }, + process: function() { + var allTables, curX, curY, dX, dY, firstTFM, i, jDat, joinData, newX, newY, orderByData, selectData, storedTblData, tbl, tblNames, _i, _j, _k, _len, _len2, _len3; + console.log("processing..."); + selectData = this.sqlData.select; + joinData = this.sqlData.join; + orderByData = this.sqlData.orderBy; + if (joinData.length > 0) { + allTables = (function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = joinData.length; _i < _len; _i++) { + i = joinData[_i]; + _results.push([i.LeftTable, i.RightTable]); + } + return _results; + })(); + tblNames = _.uniq(_.flatten(allTables)); + } else { + tblNames = [this.sqlData.singleTable]; + } + for (_i = 0, _len = tblNames.length; _i < _len; _i++) { + tbl = tblNames[_i]; + AddTable(tbl); + } + /* + for each table + get x,y of first cell of a table + get x,y of same cell from dQuery + calc dx,dy + set Table.chgX = dX + set Table.chgY = dY + */ + if (this.dQuery.length !== 0) { + for (_j = 0, _len2 = tblNames.length; _j < _len2; _j++) { + tbl = tblNames[_j]; + firstTFM = TableFields.getModelsByTableName(tbl)[0].toJSON(); + curX = firstTFM.left; + curY = firstTFM.top; + storedTblData = _.find(this.dQuery, function(i) { + return i.TableName === tbl && i.ColumnName === "*"; + }); + newX = storedTblData.OffSetX; + newY = storedTblData.OffSetY; + dX = newX - curX; + dY = newY - curY; + Tables.getModelByTableName(tbl).set_dx_dy(dX, dY).changeTopLeft(dX, dY).triggerChanges(); + } + } + for (_k = 0, _len3 = joinData.length; _k < _len3; _k++) { + jDat = joinData[_k]; + console.log(jDat); + TableFields.getModelByTableCol(jDat.LeftTable, jDat.LeftField).chgJoinLeft(); + TableFields.getModelByTableCol(jDat.RightTable, jDat.RightField).chgJoinRight(); + Joins.last().set({ + Type: jDat.Type + }); + } + /* + select clause + */ + _.each(selectData, function(item) { + var mdl; + mdl = TableFields.getModelByTableCol(item[0], item[1]); + mdl.toggleSelected(); + if (item.aliasName) { + return mdl.set({ + Alias: item.aliasName + }); + } + }); + SQLParser.resetSelectionOrder(); + _.each(orderByData, function(item) { + var mdl; + mdl = TableFields.getModelByTableCol(item.TableName, item.ColumnName); + mdl.toggleSort(); + mdl.set({ + SortOrder: SQLParser.getSelectionOrder() + }); + if (item.SortType === 'DESC') { + return mdl.set({ + Sort: 'DESC' + }); + } + }); + return this.parseNestedWhereClause(); + }, + parseNestedWhereClause: function() { + var wherePart; + wherePart = SQLParser.getWhereClause(); + if (!wherePart) return 0; + return this.parseWhereClause(wherePart); + }, + parseWhereClause: function(whereExpr) { + var i, patt, _i, _len, _ref, _results; + whereExpr = whereExpr.slice(1, (whereExpr.length - 1)); + patt = /\(.*?\)/gi; + if ((whereExpr.match(patt) || [false])[0]) { + _ref = whereExpr.match(patt); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + i = _ref[_i]; + _results.push(this.parseWhereClause(i)); + } + return _results; + } else { + return this.parseWhereCondition(whereExpr); + } + }, + parseWhereCondition: function(expr) { + var colName, leftOprnd, optr, patt, rightOprnd, tableFld, tblName, tokens; + console.log('inside parseWhereCondition...'); + expr = expr.replace(/\(|\)/g, ''); + tokens = expr.split(" "); + leftOprnd = tokens[0]; + optr = tokens[1]; + if (optr === 'LIKE') { + patt = /'.*'/; + rightOprnd = expr.match(patt)[0]; + rightOprnd = rightOprnd.replace(/'/g, ""); + } else { + rightOprnd = tokens[2]; + } + tblName = leftOprnd.split(".")[0]; + colName = leftOprnd.split(".")[1]; + tableFld = TableFields.getModelByTableCol(tblName, colName); + return BoolExprs.create({ + LeftTableField: tableFld, + Operator: optr, + RightOperand: rightOprnd + }); + } + }; +}); diff --git a/coffee/watch.sh b/coffee/watch.sh new file mode 100755 index 0000000..7157740 --- /dev/null +++ b/coffee/watch.sh @@ -0,0 +1,3 @@ +pwd +coffee -bwc *.coffee + diff --git a/conn.php b/conn.php new file mode 100644 index 0000000..f11c5bc --- /dev/null +++ b/conn.php @@ -0,0 +1,11 @@ + + diff --git a/css/design.css b/css/design.css new file mode 100644 index 0000000..73ffff0 --- /dev/null +++ b/css/design.css @@ -0,0 +1,313 @@ + body { + /*font-family: "Open Sans", arial, sans-serif;*/ + font-family: arial, sans-serif; + background-color: #FFFFFF; + font-size: 14px; + } + + select { + border-width: 0; + background-color: #EDEDED; + font-size: 10pt; + padding: 0 2px; + } + + #project-logo { + background-color: #6165A5; + padding: 3px 5px; + /*border: 1px solid #88A8E0;*/ + color: #fff; + cursor: default; + font-weight: bold; + } + + #project-logo .wb { + opacity: 0.8; + } + + #project-logo .vqd { + opacity: 1; + + } + #right-pane { + border: 1px solid #B2B2B2; + background-color: #F4F4F4; + padding: 5px 10px; + + } + + #design-pane { + height: 200px; + border: 1px solid #A3A3A3; + background-color: #FFFFFF; + margin-top: 10px; + position: relative; + overflow: scroll; + } + + .pane { + border: 1px solid #B2B2B2; + border-top-color:#A3A3A3 ; + border-bottom-color: #EFEFEF ; + padding: 5px; + font-size: 14px; + margin-top: 10px; + background-color: #D6D6D6; + + } + + .line-item { + overflow: auto; + border-bottom: 1px solid #C6C6C6; + background-color: #F9F9F9; + /*background-color: #F2F2F2;*/ + padding: 1px 3px 0; + cursor: move; + } + + .hidden-item { + display:none; + } + + .line-item > div { + float: left; + + } + .icon { + height: 15px; + width: 15px; + margin: 4px 1px 0 1px; + cursor: pointer; + } + + .line-item .icon { + opacity: 0.0; + + } + + .line-item .icon:hover { + opacity: 1.0 !important; + + } + .line-item:hover .icon { + opacity: 0.4; + + } + .icon.delete { + background-image: url('.././images/icons/cross.png'); + + } + + .icon.rearrange { + background-image: url('.././images/icons/up-down16.png'); + } + .line-item .property-editor { + margin-left: 5px; + font-size: 12px; + float: none; + } + .property-editor > div { + float:left; + height: inherit; + font-size: 14px; + } + .property-editor .field-name { + min-width: 100px; + height: inherit; + padding-top: 2px; + font-size: 10pt; + } + + .diag-table { + outline: 1px dotted #84FF8C; + float: left; + z-index: 10; + } + + .diag-table > div { + height: 20px; /* must match with those of .diag-cell*/ + width: 140px; + } + + .diag-table > .label { + /*background-color: #FFF3A5;*/ + /*background-color: #A5D3FF;*/ + background-color: #8EB6DB; + color: #ffffff; + /*padding: 2px 3px;*/ + } + + .diag-cell { + height: 20px; + min-width: 180px; + outline: 1px solid #4074CE; + background-color: #BBDBF7; + z-index: 10; + left:0; + top:0; + opacity: 0.77; + + } + + .diag-cell.label { + text-align: center; + /*background-color: #496FB7;*/ + background-color: #2F4A77; + font-weight: bold; + color: #FFF; + cursor: move; + } + + /*???*/ + .diag-join { + z-index: 0; + } + .primary-key { + font-weight: bold; + } + #sql-out.input-mode .output { + display:none; + } + #sql-out.output-mode .input { + display:none; + } + #sql-out .output { + /*height: 50px;*/ + /*width: 100px;*/ + background-color: #fff; + font-family: monospace; + padding: 2px; + } + + .operator { + margin: 3px 10px; + } + + #pane-select .alias { + width: 100px; + } + + .inline-pane { + float: left; + width: 30%; + overflow: auto ; + } + /* + .inline-pane > fieldset { + height: 50%; + } + */ + + legend { + border:1px solid #A0A0A0; + background-color: #FFFFFF; + color: #727272; + font-size: 10pt; + font-weight: bolder; + padding: 1px 5px; + } + /**/ + /*input.alias {*/ + /* height: 14px;*/ + /*}*/ + .btn-refresh { + padding: 3px 5px; + background-color: #F2DCAB; + border: 1px solid #BC811A; + font-weight: bold; + color: #663B0B; + } + + .btn-refresh:hover { + background-color: #A0866A; + color: #F2DCAB; + + + } + + .cell-dragger > .cell-edit { + float: right; + /*width:10px;*/ + /*margin-top: 2px;*/ + margin: 2px 5px 0 0; + + } + .hoverable { + opacity:0; + cursor: pointer; + } + .cell-dragger:hover .hoverable { + opacity:0.7; + } + + .property-editor span.label { + opacity: 0.7; + font-size: smaller; + + } + + .property-editor .editable { + margin-left: 5px; + float: right; + margin: 0 5px; + } + #tool-bar .tool-bar-btn { + float:left; + cursor: pointer; + padding: 2px 4px; + margin-right: 5px; + background: #777777; + color: #FFFFFF; + border: 1px solid #494949; + } + + #tool-bar { + overflow: auto; + } + .design-mode .pane { + display: block; + } + + .diag-cell.label .close { + float:right; + padding:2px; + } + + .diag-cell.label .close:hover { + background-color: #E8EFFC; + color: #6C85B5; + cursor: pointer; + } + + /*.diag-cell {*/ + /* opacity: 0.8;*/ + /*}*/ + + .orderby { + background: #4362A5; + color: #fff; + font-weight: bold; + cursor: pointer; + padding: 0 3px; + } + + /*.cell-edit {*/ + /* margin-top: 2px;*/ + /*}*/ + /**/ + #table-list { + overflow-x: auto; + overflow-y: scroll; + max-height: 300px; + + } + + #sql-text-op { + padding-left: 10px; + } + + .diag-cell .field-name { + /*overflow-x: hidden;*/ + /*font-family: Tahoma,sans-serif;*/ + opacity: 1; + } \ No newline at end of file diff --git a/css/tbl_list_overlay.css b/css/tbl_list_overlay.css new file mode 100644 index 0000000..1b3b5d4 --- /dev/null +++ b/css/tbl_list_overlay.css @@ -0,0 +1,42 @@ + +#table-list { + /*width:300px;*/ + font-family : sans-serif; + +} +#table-list .item { + border: 1px solid #D8D8D8; + cursor: pointer; +} + +#table-list .selected { + background-color: #FFEA8E; +} + +#table-list .added { + background-color: #CECECE; +} + +#table-btns { + margin-top: 10px; +} + +#table-btns .butn { + background-color: #ADCFFF; + margin-right: 10px; + cursor: pointer; + padding: 2px 4px; +} + +#table-selection { + position: fixed; + top: 30%; + left: 30%; + z-index: 10000; + background-color: #ffffff; + padding: 5px 5px; + border: 5px solid #C4C4C4; + + margin-top: 20px; + margin-bottom: 20px; +} \ No newline at end of file diff --git a/images/icons/cross.png b/images/icons/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..1514d51a3cf1b67e1c5b9ada36f1fd474e2d214a GIT binary patch literal 655 zcmV;A0&x9_P)uEoyT++I zn$b9r%cFfhHe2K68PkBu*@^<$y+7xQ$wJ~;c5aBx$R=xq*41Wo zhwQus_VOgm0hughj}MhOvs#{>Vg09Y8WxjWUJY5YW zJ?&8eG!59Cz=|E%Ns@013KLWOLV)CObIIj_5{>{#k%TEAMs_GbdDV`x-iYsGH z#=Z{USAQA>NY(}X7=3{K8# + + + + + Visual Query Designer + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + Schema : + + + + Add Table / View + +
+
+
+ +

+			
+
+ +
+ +
+
+ SELECTED FIELDS +
+ +
+
+ JOIN +
+ +
+ ORDER BY +
+
+
+ WHERE + +
+
+ +
+
+ Add tables +
+
+ + +
+
+ + GO + + + Cancel + + +
+
+ + + + + + + + + + + + + + + + + + diff --git a/js/backbone-localstorage.js b/js/backbone-localstorage.js new file mode 100644 index 0000000..091d7f3 --- /dev/null +++ b/js/backbone-localstorage.js @@ -0,0 +1,84 @@ +// A simple module to replace `Backbone.sync` with *localStorage*-based +// persistence. Models are given GUIDS, and saved into a JSON object. Simple +// as that. + +// Generate four random hex digits. +function S4() { + return (((1+Math.random())*0x10000)|0).toString(16).substring(1); +}; + +// Generate a pseudo-GUID by concatenating random hexadecimal. +function guid() { + return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); +}; + +// Our Store is represented by a single JS object in *localStorage*. Create it +// with a meaningful name, like the name you'd give a table. +var Store = function(name) { + this.name = name; + var store = localStorage.getItem(this.name); + this.data = (store && JSON.parse(store)) || {}; +}; + +_.extend(Store.prototype, { + + // Save the current state of the **Store** to *localStorage*. + save: function() { + localStorage.setItem(this.name, JSON.stringify(this.data)); + }, + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create: function(model) { + if (!model.id) model.id = model.attributes.id = guid(); + this.data[model.id] = model; + this.save(); + return model; + }, + + // Update a model by replacing its copy in `this.data`. + update: function(model) { + this.data[model.id] = model; + this.save(); + return model; + }, + + // Retrieve a model from `this.data` by id. + find: function(model) { + return this.data[model.id]; + }, + + // Return the array of all models currently in storage. + findAll: function() { + return _.values(this.data); + }, + + // Delete a model from `this.data`, returning it. + destroy: function(model) { + delete this.data[model.id]; + this.save(); + return model; + } + +}); + +// Override `Backbone.sync` to use delegate to the model or collection's +// *localStorage* property, which should be an instance of `Store`. +Backbone.sync = function(method, model, options) { + + var resp; + var store = model.localStorage || model.collection.localStorage; + + switch (method) { + case "read": resp = model.id ? store.find(model) : store.findAll(); break; + case "create": resp = store.create(model); break; + case "update": resp = store.update(model); break; + case "delete": resp = store.destroy(model); break; + } + + if (resp) { + options.success(resp); + } else { + options.error("Record not found"); + } +}; \ No newline at end of file diff --git a/js/backbone-min.js b/js/backbone-min.js new file mode 100755 index 0000000..3f0d495 --- /dev/null +++ b/js/backbone-min.js @@ -0,0 +1,33 @@ +// Backbone.js 0.5.3 +// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc. +// Backbone may be freely distributed under the MIT license. +// For all details and documentation: +// http://documentcloud.github.com/backbone +(function(){var h=this,p=h.Backbone,e;e=typeof exports!=="undefined"?exports:h.Backbone={};e.VERSION="0.5.3";var f=h._;if(!f&&typeof require!=="undefined")f=require("underscore")._;var g=h.jQuery||h.Zepto;e.noConflict=function(){h.Backbone=p;return this};e.emulateHTTP=!1;e.emulateJSON=!1;e.Events={bind:function(a,b,c){var d=this._callbacks||(this._callbacks={});(d[a]||(d[a]=[])).push([b,c]);return this},unbind:function(a,b){var c;if(a){if(c=this._callbacks)if(b){c=c[a];if(!c)return this;for(var d= +0,e=c.length;d/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")},has:function(a){return this.attributes[a]!=null},set:function(a,b){b||(b={});if(!a)return this;if(a.attributes)a=a.attributes;var c=this.attributes,d=this._escapedAttributes;if(!b.silent&&this.validate&&!this._performValidation(a,b))return!1;if(this.idAttribute in a)this.id=a[this.idAttribute]; +var e=this._changing;this._changing=!0;for(var g in a){var h=a[g];if(!f.isEqual(c[g],h))c[g]=h,delete d[g],this._changed=!0,b.silent||this.trigger("change:"+g,this,h,b)}!e&&!b.silent&&this._changed&&this.change(b);this._changing=!1;return this},unset:function(a,b){if(!(a in this.attributes))return this;b||(b={});var c={};c[a]=void 0;if(!b.silent&&this.validate&&!this._performValidation(c,b))return!1;delete this.attributes[a];delete this._escapedAttributes[a];a==this.idAttribute&&delete this.id;this._changed= +!0;b.silent||(this.trigger("change:"+a,this,void 0,b),this.change(b));return this},clear:function(a){a||(a={});var b,c=this.attributes,d={};for(b in c)d[b]=void 0;if(!a.silent&&this.validate&&!this._performValidation(d,a))return!1;this.attributes={};this._escapedAttributes={};this._changed=!0;if(!a.silent){for(b in c)this.trigger("change:"+b,this,void 0,a);this.change(a)}return this},fetch:function(a){a||(a={});var b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&& +c(b,d)};a.error=i(a.error,b,a);return(this.sync||e.sync).call(this,"read",this,a)},save:function(a,b){b||(b={});if(a&&!this.set(a,b))return!1;var c=this,d=b.success;b.success=function(a,e,f){if(!c.set(c.parse(a,f),b))return!1;d&&d(c,a,f)};b.error=i(b.error,c,b);var f=this.isNew()?"create":"update";return(this.sync||e.sync).call(this,f,this,b)},destroy:function(a){a||(a={});if(this.isNew())return this.trigger("destroy",this,this.collection,a);var b=this,c=a.success;a.success=function(d){b.trigger("destroy", +b,b.collection,a);c&&c(b,d)};a.error=i(a.error,b,a);return(this.sync||e.sync).call(this,"delete",this,a)},url:function(){var a=k(this.collection)||this.urlRoot||l();if(this.isNew())return a;return a+(a.charAt(a.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this)},isNew:function(){return this.id==null},change:function(a){this.trigger("change",this,a);this._previousAttributes=f.clone(this.attributes);this._changed=!1},hasChanged:function(a){if(a)return this._previousAttributes[a]!= +this.attributes[a];return this._changed},changedAttributes:function(a){a||(a=this.attributes);var b=this._previousAttributes,c=!1,d;for(d in a)f.isEqual(b[d],a[d])||(c=c||{},c[d]=a[d]);return c},previous:function(a){if(!a||!this._previousAttributes)return null;return this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},_performValidation:function(a,b){var c=this.validate(a);if(c)return b.error?b.error(this,c,b):this.trigger("error",this,c,b),!1;return!0}}); +e.Collection=function(a,b){b||(b={});if(b.comparator)this.comparator=b.comparator;f.bindAll(this,"_onModelEvent","_removeReference");this._reset();a&&this.reset(a,{silent:!0});this.initialize.apply(this,arguments)};f.extend(e.Collection.prototype,e.Events,{model:e.Model,initialize:function(){},toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){if(f.isArray(a))for(var c=0,d=a.length;c').hide().appendTo("body")[0].contentWindow,this.navigate(a); +this._hasPushState?g(window).bind("popstate",this.checkUrl):"onhashchange"in window&&!b?g(window).bind("hashchange",this.checkUrl):setInterval(this.checkUrl,this.interval);this.fragment=a;m=!0;a=window.location;b=a.pathname==this.options.root;if(this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;else if(this._wantsPushState&&this._hasPushState&&b&&a.hash)this.fragment=a.hash.replace(j,""),window.history.replaceState({}, +document.title,a.protocol+"//"+a.host+this.options.root+this.fragment);if(!this.options.silent)return this.loadUrl()},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.iframe.location.hash));if(a==this.fragment||a==decodeURIComponent(this.fragment))return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(a); +return f.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){var c=(a||"").replace(j,"");if(!(this.fragment==c||this.fragment==decodeURIComponent(c))){if(this._hasPushState){var d=window.location;c.indexOf(this.options.root)!=0&&(c=this.options.root+c);this.fragment=c;window.history.pushState({},document.title,d.protocol+"//"+d.host+c)}else if(window.location.hash=this.fragment=c,this.iframe&&c!=this.getFragment(this.iframe.location.hash))this.iframe.document.open().close(), +this.iframe.location.hash=c;b&&this.loadUrl(a)}}});e.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.delegateEvents();this.initialize.apply(this,arguments)};var u=/^(\S+)\s*(.*)$/,n=["model","collection","el","id","attributes","className","tagName"];f.extend(e.View.prototype,e.Events,{tagName:"div",$:function(a){return g(a,this.el)},initialize:function(){},render:function(){return this},remove:function(){g(this.el).remove();return this},make:function(a, +b,c){a=document.createElement(a);b&&g(a).attr(b);c&&g(a).html(c);return a},delegateEvents:function(a){if(a||(a=this.events))for(var b in f.isFunction(a)&&(a=a.call(this)),g(this.el).unbind(".delegateEvents"+this.cid),a){var c=this[a[b]];if(!c)throw Error('Event "'+a[b]+'" does not exist');var d=b.match(u),e=d[1];d=d[2];c=f.bind(c,this);e+=".delegateEvents"+this.cid;d===""?g(this.el).bind(e,c):g(this.el).delegate(d,e,c)}},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b= +0,c=n.length;b=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&& +a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted= +false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_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(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery); +;/* + * jQuery UI Position 1.8.16 + * + * 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(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY, +left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+= +k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-= +m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left= +d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+= +a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b), +g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery); +;/* + * jQuery UI Draggable 1.8.16 + * + * 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/Draggables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper== +"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b= +this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;if(b.iframeFix)d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options; +this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}); +this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true}, +_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.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";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b= +false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration, +10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle|| +!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&& +a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent= +this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"), +10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.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()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"), +10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top, +(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!= +"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"), +10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+ +this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&& +!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.leftg[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.topg[3])?h:!(h-this.offset.click.topg[2])?e:!(e-this.offset.click.left=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e=j&&f<=l||h>=j&&h<=l||fl)&&(e>= +i&&e<=k||g>=i&&g<=k||ek);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(), +top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle= +this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne", +nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor== +String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,l);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection(); +this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){e(this).removeClass("ui-resizable-autohide");b._handles.show()}},function(){if(!a.disabled)if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy(); +var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a= +false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"}); +this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff= +{width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio:this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis]; +if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize",b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false}, +_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height;f=f?0:c.sizeDiff.width;f={width:c.helper.width()-f,height:c.helper.height()-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f, +{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",b);this._helper&&this.helper.remove();return false},_updateVirtualBoundaries:function(b){var a=this.options,c,d,f;a={minWidth:k(a.minWidth)?a.minWidth:0,maxWidth:k(a.maxWidth)?a.maxWidth:Infinity,minHeight:k(a.minHeight)?a.minHeight:0,maxHeight:k(a.maxHeight)?a.maxHeight: +Infinity};if(this._aspectRatio||b){b=a.minHeight*this.aspectRatio;d=a.minWidth/this.aspectRatio;c=a.maxHeight*this.aspectRatio;f=a.maxWidth/this.aspectRatio;if(b>a.minWidth)a.minWidth=b;if(d>a.minHeight)a.minHeight=d;if(cb.width,h=k(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,l=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&l)b.left=i-a.minWidth;if(d&&l)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left= +null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+ +a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+ +c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]); +b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable,{version:"1.8.16"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(), +10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize,function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top- +f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var l=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:l.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n=(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(l.css("position"))){c._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType? +e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition=false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a= +e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing, +step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement= +e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top","Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset; +var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset,f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left: +a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top- +d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition, +f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25, +display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b= +e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height= +d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},k=function(b){return!isNaN(parseInt(b,10))}})(jQuery); +;/* + * jQuery UI Selectable 1.8.16 + * + * 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/Selectables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"), +selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, +c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting", +c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d= +this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom *",opacity:false,placeholder:false,revert:false,scroll:true,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")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a=== +"disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&& +!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem=c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);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");d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]}; +this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment();if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!= +document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a); +return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0], +e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a,c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset(); +c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=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 b=this.containers.length-1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(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();d.extend(this,{helper:null, +dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")}, +toArray:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+jg&&b+la[this.floating?"width":"height"]?j:g0?"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(a){var b=[],c=[],e=this._connectWith(); +if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h=d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), +this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)});return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b=0;f--)for(var g=d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h=0;b--){var c=this.items[b];if(!(c.instance!=this.currentContainer&&this.currentContainer&&c.item[0]!=this.currentItem[0])){var e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b= +this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top=e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f= +d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")|| +0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out", +a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length===1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h- +f)this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g- +this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.topthis.containment[3])?g:!(g-this.offset.click.topthis.containment[2])?f:!(f-this.offset.click.left=0;e--)if(d.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this, +this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out",g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop", +a,this._uiHash());for(e=0;e 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) { + options = $.extend({}, options); + + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // key and possibly options given, get cookie... + options = value || {}; + var decode = options.raw ? function(s) { return s; } : decodeURIComponent; + + var pairs = document.cookie.split('; '); + for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) { + if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined + } + return null; + }; +})(jQuery); diff --git a/js/jquery.min.js b/js/jquery.min.js new file mode 100644 index 0000000..198b3ff --- /dev/null +++ b/js/jquery.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/js/jsplumb.js b/js/jsplumb.js new file mode 100755 index 0000000..c89b7d0 --- /dev/null +++ b/js/jsplumb.js @@ -0,0 +1 @@ +(function(){var r=!!document.createElement("canvas").getContext;var d=!!window.SVGAngle||document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1");var a=!(r|d);var l=function(y,z,w,C){var B=function(E,D){if(E===D){return true}else{if(typeof E=="object"&&typeof D=="object"){var F=true;for(var v in E){if(!B(E[v],D[v])){F=false;break}}for(var v in D){if(!B(D[v],E[v])){F=false;break}}return F}}};for(var A=+w||0,x=y.length;A=0){delete (ax[ay]);ax.splice(ay,1);return true}}}return false},v=function(ay,ax){return I(ay,function(az,aA){ag[aA]=ax;if(i.CurrentLibrary.isDragSupported(az)){i.CurrentLibrary.setDraggable(az,ax)}})},ao=function(az,aA,ax){aA=aA==="block";var ay=null;if(ax){if(aA){ay=function(aC){aC.setVisible(true,true,true)}}else{ay=function(aC){aC.setVisible(false,true,true)}}}var aB=c(az,"id");U(aB,function(aD){if(aA&&ax){var aC=aD.sourceId===aB?1:0;if(aD.endpoints[aC].isVisible()){aD.setVisible(true)}}else{aD.setVisible(aA)}},ay)},N=function(ax){return I(ax,function(az,ay){var aA=ag[ay]==null?Y:ag[ay];aA=!aA;ag[ay]=aA;i.CurrentLibrary.setDraggable(az,aA);return aA})},x=function(ax,az){var ay=null;if(az){ay=function(aA){var aB=aA.isVisible();aA.setVisible(!aB)}}U(ax,function(aB){var aA=aB.isVisible();aB.setVisible(!aA)},ay)},E=function(aC){var aA=aC.timestamp,ax=aC.recalc,aB=aC.offset,ay=aC.elId;if(!ax){if(aA&&aA===C[ay]){return V[ay]}}if(ax||aB==null){var az=u(ay);if(az!=null){P[ay]=b(az);V[ay]=n(az);C[ay]=aA}}else{V[ay]=aB}return V[ay]},aw=function(ax,ay){var az=u(ax);var aA=c(az,"id");if(!aA||aA=="undefined"){if(arguments.length==2&&arguments[1]!=undefined){aA=ay}else{aA="jsPlumb_"+ar()}e(az,"id",aA)}return aA},am=function(az,ax,ay){az=az||function(){};ax=ax||function(){};return function(){var aA=null;try{aA=ax.apply(this,arguments)}catch(aB){k(D,"jsPlumb function failed : "+aB)}if(ay==null||(aA!==ay)){try{az.apply(this,arguments)}catch(aB){k(D,"wrapped function failed : "+aB)}}return aA}};this.connectorClass="_jsPlumb_connector";this.endpointClass="_jsPlumb_endpoint";this.overlayClass="_jsPlumb_overlay";this.Anchors={};this.Connectors={canvas:{},svg:{},vml:{}};this.Endpoints={canvas:{},svg:{},vml:{}};this.Overlays={canvas:{},svg:{},vml:{}};this.addEndpoint=function(az,aA,aJ){aJ=aJ||{};var ay=i.extend({},aJ);i.extend(ay,aA);ay.endpoint=ay.endpoint||D.Defaults.Endpoint||i.Defaults.Endpoint;ay.paintStyle=ay.paintStyle||D.Defaults.EndpointStyle||i.Defaults.EndpointStyle;az=w(az);var aB=[],aE=az.length&&az.constructor!=String?az:[az];for(var aC=0;aC0?l(aK,aJ)!=-1:true},aB=aE.length>1?{}:[],aH=function(aK,aL){if(aE.length>1){var aJ=aB[aK];if(aJ==null){aJ=[];aB[aK]=aJ}aJ.push(aL)}else{aB.push(aL)}};for(var aA in L){if(ay(aE,aA)){for(var az=0;az=4){ay.orientation=[arguments[2],arguments[3]]}if(arguments.length==6){ay.offsets=[arguments[4],arguments[5]]}}var aD=new ac(ay);aD.clone=function(){return new ac(ay)};return aD};this.makeAnchors=function(ay){var az=[];for(var ax=0;ax0?aG[0]:null,aC=aG.length>0?0:-1,aF=this,aB=function(aJ,aH,aN,aM,aI){var aL=aM[0]+(aJ.x*aI[0]),aK=aM[1]+(aJ.y*aI[1]);return Math.sqrt(Math.pow(aH-aL,2)+Math.pow(aN-aK,2))},ax=ay||function(aR,aI,aJ,aK,aH){var aM=aJ[0]+(aK[0]/2),aL=aJ[1]+(aK[1]/2);var aO=-1,aQ=Infinity;for(var aN=0;aN=0?aG.overlays[aS]:null};this.hideOverlay=function(aT){var aS=aG.getOverlay(aT);if(aS){aS.hide()}};this.showOverlay=function(aT){var aS=aG.getOverlay(aT);if(aS){aS.show()}};this.removeAllOverlays=function(){aG.overlays.splice(0,aG.overlays.length);aG.repaint()};this.removeOverlay=function(aT){var aS=aQ(aT);if(aS!=-1){aG.overlays.splice(aS,1)}};this.removeOverlays=function(){for(var aS=0;aSa6){a6=a8}}}var aZ=this.connector.compute(a1,aY,this.endpoints[a7].anchor,this.endpoints[a3].anchor,aG.paintStyleInUse.lineWidth,a6);aG.connector.paint(aZ,aG.paintStyleInUse);for(var aX=0;aX=0){aN.connections.splice(aZ,1);if(!a2){var a1=a0.endpoints[0]==aN?a0.endpoints[1]:a0.endpoints[0];a1.detach(a0,true);if(a0.endpointToDeleteOnDetach&&a0.endpointToDeleteOnDetach.connections.length==0){i.deleteEndpoint(a0.endpointToDeleteOnDetach)}}Q(a0.connector.getDisplayElements(),a0.parent);M(L,a0.scope,a0);if(!a2){ad(a0)}}};this.detachAll=function(){while(aN.connections.length>0){aN.detach(aN.connections[0])}};this.detachFrom=function(a0){var a1=[];for(var aZ=0;aZ=0){aN.connections.splice(aZ,1)}};this.getElement=function(){return aM};this.getUuid=function(){return aH};this.makeInPlaceCopy=function(){return an({anchor:aN.anchor,source:aM,paintStyle:this.paintStyle,endpoint:aL})};this.isConnectedTo=function(a1){var a0=false;if(a1){for(var aZ=0;aZ0){var a9=aK(a2.elementWithPrecedence);var bb=a9.endpoints[0]==aN?1:0;var a4=bb==0?a9.sourceId:a9.targetId;var a8=V[a4],ba=P[a4];a0.txy=[a8.left,a8.top];a0.twh=ba;a0.tElement=a9.endpoints[bb]}}a5=aN.anchor.compute(a0)}var a7=aL.compute(a5,aN.anchor.getOrientation(),aN.paintStyleInUse,a3||aN.paintStyleInUse);aL.paint(a7,aN.paintStyleInUse,aN.anchor);aN.timestamp=a6}};this.repaint=this.paint;this.removeConnection=this.detach;if(aY.isSource&&i.CurrentLibrary.isDragSupported(aM)){var aS=null,aO=null,aR=null,ax=false,aA=null;var aC=function(){aR=aN.connectorSelector();if(aN.isFull()&&!aI){return false}E({elId:aE});aB=aN.makeInPlaceCopy();aB.paint();aS=document.createElement("div");aS.style.position="absolute";var a6=u(aS);R(aS,aN.parent);var a0=aw(a6);var a7=u(aB.canvas),a5=i.CurrentLibrary.getOffset(a7),a2=aB.canvas.offsetParent!=null?aB.canvas.offsetParent.tagName.toLowerCase()==="body"?{left:0,top:0}:n(aB.canvas.offsetParent):{left:0,top:0};i.CurrentLibrary.setOffset(aS,{left:a5.left-a2.left,top:a5.top-a2.top});E({elId:a0});e(u(aN.canvas),"dragId",a0);e(u(aN.canvas),"elId",aE);var a8=new H({reference:aN.anchor,referenceCanvas:aN.canvas});aW=an({paintStyle:aN.paintStyle,endpoint:aL,anchor:a8,source:a6});if(aR==null){aN.anchor.locked=true;aR=au({sourceEndpoint:aN,targetEndpoint:aW,source:u(aM),target:u(aS),anchors:[aN.anchor,a8],paintStyle:aY.connectorStyle,hoverPaintStyle:aY.connectorHoverStyle,connector:aY.connector,overlays:aY.connectorOverlays});aR.connector.setHover(false)}else{ax=true;aR.connector.setHover(false);aD(u(aB.canvas));var a1=aR.sourceId==aE?0:1;aR.floatingAnchorIndex=a1;aN.detachFromConnection(aR);var a4=u(aN.canvas);var a3=i.CurrentLibrary.getDragScope(a4);e(a4,"originalScope",a3);var aZ=i.CurrentLibrary.getDropScope(a4);i.CurrentLibrary.setDragScope(a4,aZ);if(a1==0){aA=[aR.source,aR.sourceId,aV,a3];aR.source=u(aS);aR.sourceId=a0}else{aA=[aR.target,aR.targetId,aV,a3];aR.target=u(aS);aR.targetId=a0}aR.endpoints[a1==0?1:0].anchor.locked=true;aR.suspendedEndpoint=aR.endpoints[a1];aR.endpoints[a1]=aW}Z[a0]=aR;aW.addConnection(aR);S(ah,a0,aW);D.currentlyDragging=true};var ay=i.CurrentLibrary,aU=aY.dragOptions||{},aP=i.extend({},ay.defaultDragOptions),aQ=ay.dragEvents.start,aX=ay.dragEvents.stop,aG=ay.dragEvents.drag;aU=i.extend(aP,aU);aU.scope=aU.scope||aN.scope;aU[aQ]=am(aU[aQ],aC);aU[aG]=am(aU[aG],function(){var aZ=i.CurrentLibrary.getUIPosition(arguments);i.CurrentLibrary.setOffset(aS,aZ);at(u(aS),aZ)});aU[aX]=am(aU[aX],function(){M(ah,aO,aW);Q([aS,aW.canvas],aM);ae(aB.canvas,aM);var aZ=aR.floatingAnchorIndex==null?1:aR.floatingAnchorIndex;aR.endpoints[aZ==0?1:0].anchor.locked=false;if(aR.endpoints[aZ]==aW){if(ax&&aR.suspendedEndpoint){if(aZ==0){aR.source=aA[0];aR.sourceId=aA[1]}else{aR.target=aA[0];aR.targetId=aA[1]}i.CurrentLibrary.setDragScope(aA[2],aA[3]);aR.endpoints[aZ]=aR.suspendedEndpoint;if(aJ){aR.floatingAnchorIndex=null;aR.suspendedEndpoint.addConnection(aR);i.repaint(aA[1])}else{aR.endpoints[aZ==0?1:0].detach(aR)}}else{Q(aR.connector.getDisplayElements(),aN.parent);aN.detachFromConnection(aR)}}aN.anchor.locked=false;aN.paint();aR.setHover(false);aR.repaint();aR=null;delete aB;delete ah[aW.elementId];aW=null;delete aW;D.currentlyDragging=false});var aV=u(aN.canvas);i.CurrentLibrary.initDraggable(aV,aU)}var aD=function(a2){if(aY.isTarget&&i.CurrentLibrary.isDropSupported(aM)){var aZ=aY.dropOptions||D.Defaults.DropOptions||i.Defaults.DropOptions;aZ=i.extend({},aZ);aZ.scope=aZ.scope||aN.scope;var a5=null;var a3=i.CurrentLibrary.dragEvents.drop;var a4=i.CurrentLibrary.dragEvents.over;var a0=i.CurrentLibrary.dragEvents.out;var a1=function(){var be=u(i.CurrentLibrary.getDragObject(arguments));var a6=c(be,"dragId");var a8=c(be,"elId");var bd=c(be,"originalScope");if(bd){i.CurrentLibrary.setDragScope(be,bd)}var ba=Z[a6];var bb=ba.floatingAnchorIndex==null?1:ba.floatingAnchorIndex,bc=bb==0?1:0;if(!aN.isFull()&&!(bb==0&&!aN.isSource)&&!(bb==1&&!aN.isTarget)){if(bb==0){ba.source=aM;ba.sourceId=aE}else{ba.target=aM;ba.targetId=aE}ba.endpoints[bb].detachFromConnection(ba);if(ba.suspendedEndpoint){ba.suspendedEndpoint.detachFromConnection(ba)}ba.endpoints[bb]=aN;aN.addConnection(ba);if(!ba.suspendedEndpoint){S(L,ba.scope,ba);O(aM,aY.draggable,{})}else{var a9=ba.suspendedEndpoint.getElement(),a7=ba.suspendedEndpoint.elementId;D.fire("jsPlumbConnectionDetached",{source:bb==0?a9:ba.source,target:bb==1?a9:ba.target,sourceId:bb==0?a7:ba.sourceId,targetId:bb==1?a7:ba.targetId,sourceEndpoint:bb==0?ba.suspendedEndpoint:ba.endpoints[0],targetEndpoint:bb==1?ba.suspendedEndpoint:ba.endpoints[1],connection:ba})}i.repaint(a8);D.fire("jsPlumbConnection",{source:ba.source,target:ba.target,sourceId:ba.sourceId,targetId:ba.targetId,sourceEndpoint:ba.endpoints[0],targetEndpoint:ba.endpoints[1],connection:ba})}D.currentlyDragging=false;delete Z[a6]};aZ[a3]=am(aZ[a3],a1);aZ[a4]=am(aZ[a4],function(){var a7=i.CurrentLibrary.getDragObject(arguments);var a9=c(u(a7),"dragId");var a8=Z[a9];if(a8!=null){var a6=a8.floatingAnchorIndex==null?1:a8.floatingAnchorIndex;a8.endpoints[a6].anchor.over(aN.anchor)}});aZ[a0]=am(aZ[a0],function(){var a7=i.CurrentLibrary.getDragObject(arguments),a9=c(u(a7),"dragId"),a8=Z[a9];if(a8!=null){var a6=a8.floatingAnchorIndex==null?1:a8.floatingAnchorIndex;a8.endpoints[a6].anchor.out()}});i.CurrentLibrary.initDroppable(a2,aZ)}};aD(u(aN.canvas));return aN}};var i=window.jsPlumb=new q();i.getInstance=function(w){var v=new q(w);v.init();return v};var m=function(v,A,z,w){return function(){return i.makeAnchor(v,A,z,w)}};i.Anchors.TopCenter=m(0.5,0,0,-1);i.Anchors.BottomCenter=m(0.5,1,0,1);i.Anchors.LeftMiddle=m(0,0.5,-1,0);i.Anchors.RightMiddle=m(1,0.5,1,0);i.Anchors.Center=m(0.5,0.5,0,0);i.Anchors.TopRight=m(1,0,0,-1);i.Anchors.BottomRight=m(1,1,0,1);i.Anchors.TopLeft=m(0,0,0,-1);i.Anchors.BottomLeft=m(0,1,0,1);i.Defaults.DynamicAnchors=function(){return i.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"])};i.Anchors.AutoDefault=function(){return i.makeDynamicAnchor(i.Defaults.DynamicAnchors())}})();(function(){jsPlumb.DOMElementComponent=function(b){jsPlumb.jsPlumbUIComponent.apply(this,arguments);this.mousemove=this.dblclick=this.click=this.mousedown=this.mouseup=function(c){}};jsPlumb.Connectors.Straight=function(){this.type="Straight";var o=this;var h=null;var d,i,m,l,k,e,n,g,f,c,b;this.compute=function(s,G,C,p,z,r){var F=Math.abs(s[0]-G[0]);var v=Math.abs(s[1]-G[1]);var A=false,t=false;var u=0.45*F,q=0.45*v;F*=1.9;v*=1.9;var D=Math.min(s[0],G[0])-u;var B=Math.min(s[1],G[1])-q;var E=Math.max(2*z,r);if(F0?1:-1;var u=Math.abs(v*Math.sin(e));if(f>b){u=u*-1}var q=Math.abs(v*Math.cos(e));if(g>c){q=q*-1}return{x:t.x+(s*q),y:t.y+(s*u)}};this.perpendicularToPathAt=function(t,u,z){var v=o.pointAlongPathFrom(t,z);var s=o.gradientAtPoint(v.location);var r=Math.atan(-1/s);var w=u/2*Math.sin(r);var q=u/2*Math.cos(r);return[{x:v.x+q,y:v.y+w},{x:v.x-q,y:v.y-w}]}};jsPlumb.Connectors.Bezier=function(f){var p=this;f=f||{};this.majorAnchor=f.curviness||150;this.minorAnchor=10;var i=null;this.type="Bezier";this._findControlPoint=function(z,q,u,x,r){var w=x.getOrientation(),y=r.getOrientation();var t=w[0]!=y[0]||w[1]==y[1];var s=[];var A=p.majorAnchor,v=p.minorAnchor;if(!t){if(w[0]==0){s.push(q[0]m){m=v}if(y<0){e+=y;var z=Math.abs(y);m+=z;o[0]+=z;k+=z;c+=z;n[0]+=z}var H=Math.min(g,b);var F=Math.min(o[1],n[1]);var u=Math.min(H,F);var A=Math.max(g,b);var x=Math.max(o[1],n[1]);var s=Math.max(A,x);if(s>h){h=s}if(u<0){d+=u;var w=Math.abs(u);h+=w;o[1]+=w;g+=w;b+=w;n[1]+=w}if(E&&m=t){r=u;s=(t-m[u][0])/b[u];break}}return{segment:k[r],proportion:s,index:r}};this.compute=function(R,z,Q,s,r,I){k=[];i=[];b=[];h=[];segmentProportionals=[];e=z[0]u[0]?u[0]+((1-y)*t)-z:u[2]+(y*t)+z,y:r==0?u[3]:u[3]>u[1]?u[1]+((1-y)*t)-z:u[3]+(y*t)+z,segmentInfo:w};return x};this.perpendicularToPathAt=function(u,v,A){var w=o.pointAlongPathFrom(u,A);var t=i[w.segmentInfo.index];var s=Math.atan(-1/t);var z=v/2*Math.sin(s);var r=v/2*Math.cos(s);return[{x:w.x+r,y:w.y+z},{x:w.x-r,y:w.y-z}]}};jsPlumb.Endpoints.Dot=function(c){this.type="Dot";var b=this;c=c||{};this.radius=c.radius||10;this.defaultOffset=0.5*this.radius;this.defaultInnerRadius=this.radius/3;this.compute=function(h,e,k,g){var f=k.radius||b.radius;var d=h[0]-f;var i=h[1]-f;return[d,i,f*2,f*2,f]}};jsPlumb.Endpoints.Rectangle=function(c){this.type="Rectangle";var b=this;c=c||{};this.width=c.width||20;this.height=c.height||20;this.compute=function(i,f,l,h){var g=l.width||b.width;var e=l.height||b.height;var d=i[0]-(g/2);var k=i[1]-(e/2);return[d,k,g,e]}};jsPlumb.Endpoints.Image=function(e){this.type="Image";jsPlumb.DOMElementComponent.apply(this,arguments);var b=this,d=false;this.img=new Image();b.ready=false;this.img.onload=function(){b.ready=true};this.img.src=e.src||e.url;this.compute=function(h,f,i,g){b.anchorPoint=h;if(b.ready){return[h[0]-b.img.width/2,h[1]-b.img.height/2,b.img.width,b.img.height]}else{return[0,0,0,0]}};b.canvas=document.createElement("img"),d=false;b.canvas.style.margin=0;b.canvas.style.padding=0;b.canvas.style.outline=0;b.canvas.style.position="absolute";b.canvas.className=jsPlumb.endpointClass;jsPlumb.appendElement(b.canvas,e.parent);b.attachListeners(b.canvas,b);var c=function(l,k,h){if(!d){b.canvas.setAttribute("src",b.img.src);d=true}var i=b.img.width,g=b.img.height,f=b.anchorPoint[0]-(i/2),m=b.anchorPoint[1]-(g/2);jsPlumb.sizeCanvas(b.canvas,f,m,i,g)};this.paint=function(h,g,f){if(b.ready){c(h,g,f)}else{window.setTimeout(function(){b.paint(h,g,f)},200)}}};jsPlumb.Endpoints.Blank=function(c){var b=this;this.type="Blank";jsPlumb.DOMElementComponent.apply(this,arguments);this.compute=function(){return[0,0,10,0]};b.canvas=document.createElement("div");b.canvas.style.display="block";b.canvas.style.width="1px";b.canvas.style.height="1px";b.canvas.style.background="transparent";b.canvas.style.position="absolute";jsPlumb.appendElement(b.canvas,c.parent);this.paint=function(){}};jsPlumb.Endpoints.Triangle=function(b){this.type="Triangle";b=b||{};b.width=b.width||55;param.height=b.height||55;this.width=b.width;this.height=b.height;this.compute=function(h,e,k,g){var f=k.width||self.width;var d=k.height||self.height;var c=h[0]-(f/2);var i=h[1]-(d/2);return[c,i,f,d]}};var a=function(){var c=true,b=this;this.setVisible=function(d){c=d;b.connection.repaint()};this.isVisible=function(){return c};this.hide=function(){b.setVisible(false)};this.show=function(){b.setVisible(true)}};jsPlumb.Overlays.Arrow=function(g){this.type="Arrow";a.apply(this);g=g||{};var c=this;this.length=g.length||20;this.width=g.width||20;this.id=g.id;this.connection=g.connection;var f=(g.direction||1)<0?-1:1;var d=g.paintStyle||{lineWidth:1};this.loc=g.location==null?0.5:g.location;var b=g.foldback||0.623;var e=function(h,k){if(b==0.5){return h.pointOnPath(k)}else{var i=0.5-b;return h.pointAlongPathFrom(k,f*c.length*i)}};this.computeMaxSize=function(){return c.width*1.5};this.draw=function(l,r,x){var z=l.pointAlongPathFrom(c.loc,f*(c.length/2));var u=l.pointAlongPathFrom(c.loc,-1*f*(c.length/2)),C=u.x,B=u.y;var s=l.perpendicularToPathAt(c.loc,c.width,-1*f*(c.length/2));var k=e(l,c.loc);if(c.loc==1){var i=l.pointOnPath(c.loc);var w=(i.x-z.x)*f,v=(i.y-z.y)*f;k.x+=w;k.y+=v;u.x+=w;u.y+=v;s[0].x+=w;s[0].y+=v;s[1].x+=w;s[1].y+=v;z.x+=w;z.y+=v}if(c.loc==0){var i=l.pointOnPath(c.loc);var t=b>1?k:{x:s[0].x+((s[1].x-s[0].x)/2),y:s[0].y+((s[1].y-s[0].y)/2)};var w=(i.x-t.x)*f,v=(i.y-t.y)*f;k.x+=w;k.y+=v;u.x+=w;u.y+=v;s[0].x+=w;s[0].y+=v;s[1].x+=w;s[1].y+=v;z.x+=w;z.y+=v}var p=Math.min(z.x,s[0].x,s[1].x);var o=Math.max(z.x,s[0].x,s[1].x);var n=Math.min(z.y,s[0].y,s[1].y);var m=Math.max(z.y,s[0].y,s[1].y);var A={hxy:z,tail:s,cxy:k},y=d.strokeStyle||r.strokeStyle,q=d.fillStyle||r.strokeStyle,h=d.lineWidth||r.lineWidth;c.paint(l,A,h,y,q,x);return[p,o,n,m]}};jsPlumb.Overlays.PlainArrow=function(c){c=c||{};var b=jsPlumb.extend(c,{foldback:1});jsPlumb.Overlays.Arrow.call(this,b);this.type="PlainArrow"};jsPlumb.Overlays.Diamond=function(d){d=d||{};var b=d.length||40;var c=jsPlumb.extend(d,{length:b/2,foldback:2});jsPlumb.Overlays.Arrow.call(this,c);this.type="Diamond"};jsPlumb.Overlays.Label=function(e){this.type="Label";jsPlumb.DOMElementComponent.apply(this,arguments);a.apply(this);this.labelStyle=e.labelStyle||jsPlumb.Defaults.LabelStyle;this.labelStyle.font=this.labelStyle.font||"12px sans-serif";this.label=e.label||"banana";this.connection=e.connection;this.id=e.id;var l=this;var i=null,f=null,d=null,c=null;this.location=e.location||0.5;this.cachedDimensions=null;var k=false,d=null,b=document.createElement("div");b.style.position="absolute";b.style.font=l.labelStyle.font;b.style.color=l.labelStyle.color||"black";if(l.labelStyle.fillStyle){b.style.background=l.labelStyle.fillStyle}if(l.labelStyle.borderWidth>0){var h=l.labelStyle.borderStyle?l.labelStyle.borderStyle:"black";b.style.border=l.labelStyle.borderWidth+"px solid "+h}if(l.labelStyle.padding){b.style.padding=l.labelStyle.padding}var g=e._jsPlumb.overlayClass+" "+(l.labelStyle.cssClass?l.labelStyle.cssClass:e.cssClass?e.cssClass:"");b.className=g;jsPlumb.appendElement(b,e.connection.parent);jsPlumb.getId(b);l.attachListeners(b,l);var m=l.setVisible;l.setVisible=function(n){m(n);b.style.display=n?"block":"none"};this.paint=function(n,p,o){if(!k){n.appendDisplayElement(b);l.attachListeners(b,n);k=true}b.style.left=(o[0]+p.minx)+"px";b.style.top=(o[1]+p.miny)+"px"};this.getTextDimensions=function(n){d=typeof l.label=="function"?l.label(l):l.label;b.innerHTML=d.replace(/\r\n/g,"
");var p=jsPlumb.CurrentLibrary.getElementObject(b),o=jsPlumb.CurrentLibrary.getSize(p);return{width:o[0],height:o[1]}};this.computeMaxSize=function(n){var o=l.getTextDimensions(n);return o.width?Math.max(o.width,o.height)*1.5:0};this.draw=function(p,r,q){var t=l.getTextDimensions(p);if(t.width!=null){var s=p.pointOnPath(l.location);var o=s.x-(t.width/2);var n=s.y-(t.height/2);l.paint(p,{minx:o,miny:n,td:t,cxy:s},q);return[o,o+t.width,n,n+t.height]}else{return[0,0,0,0]}}}})();(function(){var h={"stroke-linejoin":"joinstyle",joinstyle:"joinstyle",endcap:"endcap",miterlimit:"miterlimit"};if(document.createStyleSheet){document.createStyleSheet().addRule(".jsplumb_vml","behavior:url(#default#VML);position:absolute;");document.createStyleSheet().addRule("jsplumb\\:textbox","behavior:url(#default#VML);position:absolute;");document.createStyleSheet().addRule("jsplumb\\:oval","behavior:url(#default#VML);position:absolute;");document.createStyleSheet().addRule("jsplumb\\:rect","behavior:url(#default#VML);position:absolute;");document.createStyleSheet().addRule("jsplumb\\:stroke","behavior:url(#default#VML);position:absolute;");document.createStyleSheet().addRule("jsplumb\\:shape","behavior:url(#default#VML);position:absolute;");document.namespaces.add("jsplumb","urn:schemas-microsoft-com:vml")}var c=1000,d=function(p,q){for(var n in q){p[n]=q[n]}},m=function(n,q,r){r=r||{};var p=document.createElement("jsplumb:"+n);p.className=(r["class"]?r["class"]+" ":"")+"jsplumb_vml";l(p,q);d(p,r);return p},l=function(p,n){p.style.left=n[0]+"px";p.style.top=n[1]+"px";p.style.width=n[2]+"px";p.style.height=n[3]+"px";p.style.position="absolute"},g=function(n){return Math.floor(n*c)},a=function(p,n){var v=p,u=function(o){return o.length==1?"0"+o:o},q=function(o){return u(Number(o).toString(16))},r=/(rgb[a]?\()(.*)(\))/;if(p.match(r)){var t=p.match(r)[2].split(",");v="#"+q(t[0])+q(t[1])+q(t[2]);if(!n&&t.length==4){v=v+q(t[3])}}return v},f=function(s,r,p){var u={};if(r.strokeStyle){u.stroked="true";u.strokecolor=a(r.strokeStyle,true);u.strokeweight=r.lineWidth+"px"}else{u.stroked="false"}if(r.fillStyle){u.filled="true";u.fillcolor=a(r.fillStyle,true)}else{u.filled="false"}if(r.dashstyle){if(p.strokeNode==null){p.strokeNode=m("stroke",[0,0,0,0],{dashstyle:r.dashstyle});s.appendChild(p.strokeNode)}else{p.strokeNode.dashstyle=r.dashstyle}}else{if(r["stroke-dasharray"]&&r.lineWidth){var o=r["stroke-dasharray"].indexOf(",")==-1?" ":",",t=r["stroke-dasharray"].split(o),n="";for(var q=0;q0&&F>0&&z=z&&B[2]<=F&&B[3]>=F)){return true}}var D=v.canvas.getContext("2d").getImageData(parseInt(z),parseInt(F),1,1);return D.data[0]!=0||D.data[1]!=0||D.data[2]!=0||D.data[3]!=0}return false};var u=false;var t=false,y=null,x=false;var w=function(A,z){return A!=null&&f(A,z)};this.mousemove=function(C){var E=e(C),B=i(C),A=document.elementFromPoint(B[0],B[1]),D=w(A,"_jsPlumb_overlay");var z=o==null&&(w(A,"_jsPlumb_endpoint")||w(A,"_jsPlumb_connector"));if(!u&&z&&v._over(C)){u=true;v.fire("mouseenter",v,C);return true}else{if(u&&(!v._over(C)||!z)&&!D){u=false;v.fire("mouseexit",v,C)}}v.fire("mousemove",v,C)};this.click=function(z){if(u&&v._over(z)&&!x){v.fire("click",v,z)}x=false};this.dblclick=function(z){if(u&&v._over(z)&&!x){v.fire("dblclick",v,z)}x=false};this.mousedown=function(z){if(v._over(z)&&!t){t=true;y=m(s(v.canvas));v.fire("mousedown",v,z)}};this.mouseup=function(z){t=false;v.fire("mouseup",v,z)}};var p=function(u){var t=document.createElement("canvas");jsPlumb.appendElement(t,u.parent);t.style.position="absolute";if(u["class"]){t.className=u["class"]}u._jsPlumb.getId(t,u.uuid);return t};var d=jsPlumb.CanvasConnector=function(x){n.apply(this,arguments);var t=function(B,z){u.ctx.save();jsPlumb.extend(u.ctx,z);if(z.gradient){var A=u.createGradient(B,u.ctx);for(var y=0;y0?1:-1}}var b={subtract:function(m,l){return{x:m.x-l.x,y:m.y-l.y}},dotProduct:function(m,l){return m.x*l.x+m.y*l.y},square:function(l){return Math.sqrt(l.x*l.x+l.y*l.y)},scale:function(m,l){return{x:m.x*l,y:m.y*l}}},d=Math.pow(2,-65),h=function(y,x){for(var s=[],v=x.length-1,r=2*v-1,t=[],w=[],o=[],p=[],q=[[1,0.6,0.3,0.1],[0.4,0.6,0.6,0.4],[0.1,0.3,0.6,1]],u=0;u<=v;u++){t[u]=b.subtract(x[u],y)}for(u=0;u<=v-1;u++){w[u]=b.subtract(x[u+1],x[u]);w[u]=b.scale(w[u],3)}for(u=0;u<=v-1;u++){for(var n=0;n<=v;n++){o[u]||(o[u]=[]);o[u][n]=b.dotProduct(w[u],t[n])}}for(u=0;u<=r;u++){p[u]||(p[u]=[]);p[u].y=0;p[u].x=parseFloat(u)/r}r=v-1;for(t=0;t<=v+r;t++){w=Math.min(t,v);for(u=Math.max(0,t-r);u<=w;u++){j=t-u;p[u+j].y+=o[j][u]*q[j][u]}}v=x.length-1;p=k(p,2*v-1,s,0);r=b.subtract(y,x[0]);o=b.square(r);for(u=q=0;u=64){y[0]=(E[0].x+E[D].x)/2;return 1}var s,r,p;v=E[0].y-E[D].y;w=E[D].x-E[0].x;A=E[0].x*E[D].y-E[D].x*E[0].y;t=max_distance_below=0;for(r=1;rt){t=p}else{if(p0?1:-1,r=null;n2;a==null&&(a=[]);if(x&&a.reduce===x)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(y&&a.reduceRight===y)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g, +c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,c,b){var e;D(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.filter===z)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(A&&a.every===A)return a.every(c, +b);j(a,function(a,g,h){if(!(e=e&&c.call(b,a,g,h)))return o});return e};var D=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(B&&a.some===B)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return q&&a.indexOf===q?a.indexOf(c)!=-1:b=D(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(c.call?c||a:a[c]).apply(a, +d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex= +function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after= +function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=I||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],d;for(d in a)m.call(a,d)&&(b[b.length]=d);return b};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)b[d]!==void 0&&(a[d]=b[d])});return a};b.defaults=function(a){j(i.call(arguments, +1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(m.call(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a=== +Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!m.call(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)== +"[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){s._=F;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a),function(c){J(c, +b[c]=a[c])})};var K=0;b.uniqueId=function(a){var b=K++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape,function(a,b){return"',_.escape("+b.replace(/\\'/g,"'")+"),'"}).replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g, +"'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};var n=function(a){this._wrapped=a};b.prototype=n.prototype;var u=function(a,c){return c?b(a).chain():a},J=function(a,c){n.prototype[a]=function(){var a=i.call(arguments);H.call(a,this._wrapped);return u(c.apply(b, +a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];n.prototype[a]=function(){b.apply(this._wrapped,arguments);return u(this._wrapped,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];n.prototype[a]=function(){return u(b.apply(this._wrapped,arguments),this._chain)}});n.prototype.chain=function(){this._chain=true;return this};n.prototype.value=function(){return this._wrapped}}).call(this); diff --git a/lib.php b/lib.php new file mode 100644 index 0000000..34d64a6 --- /dev/null +++ b/lib.php @@ -0,0 +1,16 @@ + + class="btn " > + + + + + \ No newline at end of file diff --git a/table_sel_list.php b/table_sel_list.php new file mode 100644 index 0000000..ccce07b --- /dev/null +++ b/table_sel_list.php @@ -0,0 +1,36 @@ + +
+
+ Add tables +
+
+ +
+ +
+
+ + GO + + + Cancel + + +
+