Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Little grid fix #4

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
83 changes: 50 additions & 33 deletions data/grid/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
},
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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();
},
Expand All @@ -213,4 +230,4 @@ $.Controller.extend("Mxui.Data.Grid",{

});

})
})
8 changes: 2 additions & 6 deletions data/grid/views/init.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
<thead>
<tr>
<%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]}) %>
<%}%>
</tr>
</thead>
<tbody>
<tr class='loading'>
<td colspan='<%=count %>'>Loading ...</td>
</tr>


</tbody>

</table>
2 changes: 1 addition & 1 deletion data/grid/views/list.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<tr <%= items[i]%> tabindex='0'>
<%== $.View(row, items[i] ) %>
</tr>
<%}%>
<% } %>
2 changes: 1 addition & 1 deletion data/grid2/scripts/standalone/modelfixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@

var parts = fullName.split(/\./),
shortName = parts.pop(),
current = $.Class.getObject(parts.join('.')),
current = $.String.getObject(parts.join('.')),
namespace = current;


Expand Down
5 changes: 2 additions & 3 deletions data/order/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})

Expand Down
7 changes: 5 additions & 2 deletions form/combobox/funcunit.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../funcunit/qunit/qunit.css" />
<link rel="stylesheet" type="text/css" href="../../../funcunit/qunit/qunit.css" />
<title>FuncUnit Test</title>
<style>
body {
margin: 0px; padding: 0px;
}
</style>
<script type='text/javascript' src='../../steal/steal.js?steal[app]=mxui/combobox/test/funcunit'></script>
<script type='text/javascript' src='../../../steal/steal.js'></script>
</head>
<body>

Expand All @@ -17,4 +17,7 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</body>
<script type='text/javascript' >
steal('mxui/form/combobox/test/funcunit')
</script>
</html>
1 change: 0 additions & 1 deletion form/combobox/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ steal('mxui/form/combobox').then(function(){
className : className
})


var items = [], option, $option;
el.find("option").each(function(){
$option = $(this);
Expand Down
5 changes: 2 additions & 3 deletions form/combobox/select/test/funcunit/funcunit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
steal
.plugins("funcunit")
.then("select_test")
steal("funcunit")
.then("mxui/form/combobox/test/select_test")
41 changes: 20 additions & 21 deletions form/combobox/test/funcunit/funcunit.js
Original file line number Diff line number Diff line change
@@ -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")
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")
2 changes: 1 addition & 1 deletion form/combobox/test/funcunit/positioning4a_tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module("combobox4 test", {
setup: function(){
S.open("//mxui/combobox/positioning4a.html");
S.open("//mxui/form/combobox/positioning4a.html");
}
})

Expand Down
7 changes: 5 additions & 2 deletions layout/fill/fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ steal('jquery/dom/dimensions', 'jquery/event/resize').then(function( $ ) {
if ( thePage ) {
options.parent = $(window)
}


this.each(function(){

Expand All @@ -138,6 +138,7 @@ steal('jquery/dom/dimensions', 'jquery/event/resize').then(function( $ ) {
})




//add a resize to get things going
var func = function() {
Expand All @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions layout/fit/fit.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
left: 300px;
}
</style>
<link type="text/css" href="../../../mxui/combobox/combobox.css" rel="stylesheet" />
<link type="text/css" href="../../../mxui/form/combobox/combobox.css" rel="stylesheet" />
</head>
<body>
<div id='fitter' class="fittable">Demo Fittable</div>
Expand Down Expand Up @@ -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);
Expand All @@ -102,23 +102,23 @@
$("#fittable2")//.css("opacity",0)
.html( items(30));
$("#target2").click(function(ev){
$("#fittable2").fit({
$("#fittable2").mxui_layout_fit({
within:300,
of:$("#target2")
})
});

$("#fittable3").html( items(30));
$("#target3").click(function(ev){
$("#fittable3").fit({
$("#fittable3").mxui_layout_fit({
within:300,
of:$("#target3")
});
});

$("#fittable4").html( items(20));
$("#target4").click(function(ev){
$("#fittable4").fit({
$("#fittable4").mxui_layout_fit({
within:300,
of:$("#target4")
});
Expand Down
1 change: 1 addition & 0 deletions layout/modal/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ <h3>Some Modal</h3>
});
})
})

</script>
</body>
</html>
Loading