diff --git a/data/grid/grid.js b/data/grid/grid.js index 3aa83c5..e071bb8 100644 --- a/data/grid/grid.js +++ b/data/grid/grid.js @@ -46,7 +46,10 @@ $.Controller.extend("Mxui.Data.Grid",{ defaults: { columns: {}, params: new Mxui.Data, - row : null, + initTemplate: '//mxui/data/grid/views/init.ejs', + listTemplate: '//mxui/data/grid/views/list.ejs', + titleTemplate: '//mxui/data/grid/views/th.ejs', + rowTemplate : null, model : null, noItems : "No Items", // if true, can sort by multiple columns at a time @@ -60,7 +63,23 @@ $.Controller.extend("Mxui.Data.Grid",{ // immediately uses the model to request items for the grid loadImmediate: true, - selectable : true + selectable : true, + + // default crud manipulations + + refresh: function(tbody, elt, newElt){ + elt.replaceWith(newElt) + tbody.resize() + }, + append: function(tbody, newElt){ + tbody.prepend(newElt) + tbody.resize() + }, + remove: function(tbody, elt){ + elt.remove() + tbody.resize() + } + }, listensTo : ["select","deselect"] }, @@ -78,7 +97,7 @@ $.Controller.extend("Mxui.Data.Grid",{ for(var name in this.options.columns){ count++; } - this.element.append( this.view({columns: this.options.columns, count: count}) ) + this.element.append( this.view(this.options.initTemplate,{titleTemplate: this.options.titleTemplate, columns: this.options.columns, count: count}) ) this.element.children('table').mxui_layout_table_scroll({ filler: this.options.filler @@ -124,15 +143,15 @@ $.Controller.extend("Mxui.Data.Grid",{ this.options.params.attr('updating', false); - var trs = $(this.view('list',{ - row : this.options.row, + var trs = $(this.view(this.options.listTemplate,{ + rowTemplate : this.options.rowTemplate, items: items })); if(clear){ this.empty(); } - + this.append(trs); // update the items this.options.params.attr('count',items.count) @@ -141,50 +160,47 @@ $.Controller.extend("Mxui.Data.Grid",{ if(attr !== 'count' && attr !== 'updating'){ //want to throttle for rapid updates params.attr('updating', true) - clearTimeout(this.newRequestTimer,100) - this.newRequestTimer = setTimeout(this.callback('newRequest', attr, val)) + clearTimeout(this.newRequestTimer) + this.newRequestTimer = setTimeout(this.callback('newRequest', attr, val), 100) } }, newRequest : function(attr, val){ - var clear = true; + var clear = true; if(!this.options.offsetEmpties && attr == "offset"){ // if offset changes and we have offsetEmpties false clear = false; } - this.options.model.findAll(this.options.params.attrs(), this.callback('list', clear)) + this.makeRequest(clear) }, + makeRequest: function(clear){ + this.options.model.findAll(this.options.params.attrs(), this.callback('list', clear)) + }, + _getRows: function(viewTemplateOption, items){ + items = ( $.isArray(items) || items instanceof $.Model.List ) ? items : [items] + return $(this.view(this.options.listTemplate,{ + rowTemplate : this.options[viewTemplateOption], + items: items + }, { columns: this.options.columns, renderer: this.options.renderer } )); + }, + /** * Listen for updates and replace the text of the list * @param {Object} called * @param {Object} item */ "{model} updated" : function(model, ev, item){ - var el = item.elements(this.element).html(this.options.row, item); - if(this.options.updated){ - this.options.updated(this.element, el, item) + var el = item.elements(this.element) + if (el.length > 0){ + var newElt= this._getRows('rowTemplate', item) + this.options.refresh(this.$.tbody, el, newElt) } - this.element.resize() }, "{model} created" : function(model, ev, item){ - var newEl = $($.View("//mxui/data/grid/views/list",{ - items : [item], - row: this.options.row - })) - if(this.options.append){ - this.options.append(this.element, newEl, item) - }else{ - this.append(newEl) - //newEl.appendTo(this.element).slideDown(); - } + var newEl = this._getRows('rowTemplate', item) + this.options.append(this.$.tbody, newEl) }, "{model} destroyed" : function(model, ev, item){ var el = item.elements(this.element) - if(this.options.remove){ - this.options.remove(this.element,el, item) - }else{ - el.slideUp( function(){ - el.remove(); - }) - } + this.options.remove(this.$.tbody, el) }, /** * Insert rows into the table @@ -202,8 +218,9 @@ $.Controller.extend("Mxui.Data.Grid",{ * Remove all children from the table */ empty: function(){ - this.element.children(":first").mxui_layout_table_scroll("empty") + this.element.children(".mxui_layout_table_scroll").mxui_layout_table_scroll("empty") }, + "select" : function(el, ev){ ev.preventDefault(); }, @@ -213,4 +230,4 @@ $.Controller.extend("Mxui.Data.Grid",{ }); -}) \ No newline at end of file +}) diff --git a/data/grid/views/init.ejs b/data/grid/views/init.ejs index ae0ca07..70d3bc3 100644 --- a/data/grid/views/init.ejs +++ b/data/grid/views/init.ejs @@ -2,15 +2,11 @@ <%for(var col in columns){%> - <%== view('//mxui/data/grid/views/th', {name: col, title: columns[col]}) %> + <%== $.View('//mxui/data/grid/views/th', {name: col, title: columns[col]}) %> <%}%> - - Loading ... - - + - \ No newline at end of file diff --git a/data/grid/views/list.ejs b/data/grid/views/list.ejs index 9f8cee6..82ba3b4 100644 --- a/data/grid/views/list.ejs +++ b/data/grid/views/list.ejs @@ -2,4 +2,4 @@ tabindex='0'> <%== $.View(row, items[i] ) %> -<%}%> \ No newline at end of file +<% } %> \ No newline at end of file diff --git a/data/grid2/scripts/standalone/modelfixture.js b/data/grid2/scripts/standalone/modelfixture.js index b4cc062..d327302 100644 --- a/data/grid2/scripts/standalone/modelfixture.js +++ b/data/grid2/scripts/standalone/modelfixture.js @@ -505,7 +505,7 @@ var parts = fullName.split(/\./), shortName = parts.pop(), - current = $.Class.getObject(parts.join('.')), + current = $.String.getObject(parts.join('.')), namespace = current; diff --git a/data/order/order.js b/data/order/order.js index 4ad4335..019e4bc 100644 --- a/data/order/order.js +++ b/data/order/order.js @@ -80,9 +80,8 @@ $.Controller('Mxui.Data.Order', order.unshift(newOrder) } } - this.options.params.attrs({ - 'order' : order, - offset: 0}) + this.options.params.attr('offset', 0) + this.options.params.attr('order', order) } }) diff --git a/form/combobox/funcunit.html b/form/combobox/funcunit.html index c4360e7..460519e 100644 --- a/form/combobox/funcunit.html +++ b/form/combobox/funcunit.html @@ -1,13 +1,13 @@ - + FuncUnit Test - + @@ -17,4 +17,7 @@

    + \ No newline at end of file diff --git a/form/combobox/select/select.js b/form/combobox/select/select.js index 7ab46e8..94edf1f 100644 --- a/form/combobox/select/select.js +++ b/form/combobox/select/select.js @@ -16,7 +16,6 @@ steal('mxui/form/combobox').then(function(){ className : className }) - var items = [], option, $option; el.find("option").each(function(){ $option = $(this); diff --git a/form/combobox/select/test/funcunit/funcunit.js b/form/combobox/select/test/funcunit/funcunit.js index 5ac5d82..3eb786b 100644 --- a/form/combobox/select/test/funcunit/funcunit.js +++ b/form/combobox/select/test/funcunit/funcunit.js @@ -1,3 +1,2 @@ -steal - .plugins("funcunit") - .then("select_test") \ No newline at end of file +steal("funcunit") + .then("mxui/form/combobox/test/select_test") \ No newline at end of file diff --git a/form/combobox/test/funcunit/funcunit.js b/form/combobox/test/funcunit/funcunit.js index 797738b..0faf848 100644 --- a/form/combobox/test/funcunit/funcunit.js +++ b/form/combobox/test/funcunit/funcunit.js @@ -1,21 +1,20 @@ -steal - .plugins("funcunit") - .then("smoke_tests", - "positioning4a_tests", - "positioning4b_tests", - "positioning4c_tests", - "positioning4d_tests", - "positioning4e_tests", - "positioning5a_tests", - "positioning5b_tests", - "positioning5c_tests", - "positioning5d_tests", - "positioning5e_tests", - "positioning6a_tests", - "positioning6b_tests", - "positioning6c_tests", - "positioning6d_tests", - "positioning6e_tests", - "autocomplete7_tests", - "api8a_tests", - "api8b_tests") \ No newline at end of file +steal("funcunit") + .then("./smoke_tests", + "./positioning4a_tests", + "./positioning4b_tests", + "./positioning4c_tests", + "./positioning4d_tests", + "./positioning4e_tests", + "./positioning5a_tests", + "./positioning5b_tests", + "./positioning5c_tests", + "./positioning5d_tests", + "./positioning5e_tests", + "./positioning6a_tests", + "./positioning6b_tests", + "./positioning6c_tests", + "./positioning6d_tests", + "./positioning6e_tests", + "./autocomplete7_tests", + "./api8a_tests", + "./api8b_tests") \ No newline at end of file diff --git a/form/combobox/test/funcunit/positioning4a_tests.js b/form/combobox/test/funcunit/positioning4a_tests.js index 92b1246..8f0c4ad 100644 --- a/form/combobox/test/funcunit/positioning4a_tests.js +++ b/form/combobox/test/funcunit/positioning4a_tests.js @@ -1,6 +1,6 @@ module("combobox4 test", { setup: function(){ - S.open("//mxui/combobox/positioning4a.html"); + S.open("//mxui/form/combobox/positioning4a.html"); } }) diff --git a/layout/fill/fill.js b/layout/fill/fill.js index 39de2ff..e0d0854 100644 --- a/layout/fill/fill.js +++ b/layout/fill/fill.js @@ -115,7 +115,7 @@ steal('jquery/dom/dimensions', 'jquery/event/resize').then(function( $ ) { if ( thePage ) { options.parent = $(window) } - + this.each(function(){ @@ -138,6 +138,7 @@ steal('jquery/dom/dimensions', 'jquery/event/resize').then(function( $ ) { }) + //add a resize to get things going var func = function() { @@ -154,14 +155,16 @@ steal('jquery/dom/dimensions', 'jquery/event/resize').then(function( $ ) { $.extend(filler, { parentResize: function( ev ) { + if (ev.data.filler.is(':hidden')) { return; } - + var parent = $(this), isWindow = this == window, container = (isWindow ? $(document.body) : parent), + //if the parent bleeds margins, we don't care what the last element's margin is isBleeder = bleeder(parent), children = container.children().filter(function() { diff --git a/layout/fit/fit.html b/layout/fit/fit.html index 803ff70..760fbff 100644 --- a/layout/fit/fit.html +++ b/layout/fit/fit.html @@ -42,7 +42,7 @@ left: 300px; } - +
    Demo Fittable
    @@ -93,7 +93,7 @@ // .css("position", "absolute") .html( items(5)); $("#target1").click(function(ev){ - $("#fittable1").fit({ + $("#fittable1").mxui_layout_fit({ within:300, of:$("#target1") }).css("opacity",1); @@ -102,7 +102,7 @@ $("#fittable2")//.css("opacity",0) .html( items(30)); $("#target2").click(function(ev){ - $("#fittable2").fit({ + $("#fittable2").mxui_layout_fit({ within:300, of:$("#target2") }) @@ -110,7 +110,7 @@ $("#fittable3").html( items(30)); $("#target3").click(function(ev){ - $("#fittable3").fit({ + $("#fittable3").mxui_layout_fit({ within:300, of:$("#target3") }); @@ -118,7 +118,7 @@ $("#fittable4").html( items(20)); $("#target4").click(function(ev){ - $("#fittable4").fit({ + $("#fittable4").mxui_layout_fit({ within:300, of:$("#target4") }); diff --git a/layout/modal/modal.html b/layout/modal/modal.html index 5d6d482..c2bea05 100644 --- a/layout/modal/modal.html +++ b/layout/modal/modal.html @@ -104,6 +104,7 @@

    Some Modal

    }); }) }) + diff --git a/layout/positionable/positionable.html b/layout/positionable/positionable.html index f717ead..fad1da2 100644 --- a/layout/positionable/positionable.html +++ b/layout/positionable/positionable.html @@ -124,14 +124,13 @@

    Positionable

    Drag me!
    - + \ No newline at end of file diff --git a/nav/menu/menu.js b/nav/menu/menu.js index 5f216b9..52d940b 100644 --- a/nav/menu/menu.js +++ b/nav/menu/menu.js @@ -111,7 +111,9 @@ steal('mxui/layout/positionable','mxui/nav/menuable','jquery/event/hover').then( ">show" : function(el, ev){ if(ev.target == this.element[0]){ this.element.show(); - } + // prevent the event to trigger the positionable "show" handler + ev.stopPropagation() + } } }); @@ -145,7 +147,7 @@ steal('mxui/layout/positionable','mxui/nav/menuable','jquery/event/hover').then( */ Mxui.Nav.Menu.extend("Mxui.UI.Menu",{ defaults: { - types : [Mxui.Layout.Positionable("Mxui.UI.TopLeft",{defaults: {my: "left top",at: "right top"}},{}), + types : [Mxui.Layout.Positionable("Mxui.UI.TopLeft",{defaults: {my: "left top",at: "right top", keep:true}},{}), Mxui.UI.Highlight], select_event : "hoverenter", child_selector : "li", diff --git a/nav/menuable/menuable.js b/nav/menuable/menuable.js index e07616b..d0e594a 100644 --- a/nav/menuable/menuable.js +++ b/nav/menuable/menuable.js @@ -59,7 +59,7 @@ steal('jquery/controller', if(this.activating) return; this.activating = true; - var options = this.options, oldActive = this.find("."+options.active+":first"), self= this; + var options = this.options, oldActive = this.element.children("."+options.active+":first"), self= this; ev.pause(); var doThis = function(){