Skip to content

Commit

Permalink
move assets to assets dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj Singh committed Oct 18, 2011
1 parent 4e3ce0d commit fcd8e84
Show file tree
Hide file tree
Showing 33 changed files with 10,290 additions and 1 deletion.
Binary file added app/assets/images/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/no.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/site.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/sort_by_asc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/sort_by_desc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/sort_by_nothing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions app/assets/javascripts/advance_search/act_on_result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var AdminData = AdminData || {};

AdminData.actOnResult = {

action: function(action_type) {
var formData = $('#advance_search_form').data('admin_data_form_array'),
parameterizedData;

formData.push({
'name': 'admin_data_advance_search_action_type',
'value': action_type
});

parameterizedData = $.param(formData);

$.ajax({
url: $('#advance_search_form').attr('action'),
type: 'post',
dataType: 'json',
data: parameterizedData,
success: function(json) {
AdminData.actOnResult.successCallback(json);
}
});
},

successCallback: function(json) {
$('#results').text(json.success);
}

};

$('#advance_search_delete_all').live('click', function() {
if (window.confirm('Are you sure?')) {
AdminData.actOnResult.action('delete');
}
return false;
});

$('#advance_search_destroy_all').live('click', function() {
if (window.confirm('Are you sure?')) {
AdminData.actOnResult.action('destroy');
}
return false;
});
83 changes: 83 additions & 0 deletions app/assets/javascripts/advance_search/advance_search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
var AdminData = AdminData || {};

AdminData.advanceSearch = {

buildFirstRow: function() {

var img = $('<img />', {
src: '/admin_data/public/images/add.png'
});

$('#advance_search_table').append(this.buildRow())
.find('tr td:last a')
.attr('id','add_row_link_1')
.removeClass('remove_row')
.addClass('add_row_link')
.html('')
.append(img);
},

buildCol1: function() {
var i, col = $('<select />', { className: 'col1' }).append($('<option />')),
tableStructure = $('#advance_search_table').data('table_structure');

for (i in tableStructure) {
$('<option />', {
text: i,
value: i
}).appendTo(col);
}
return $('<td />').append(col);
},

buildCol2: function() {
var select = $('<select />', { className: 'col2', disabled: 'disabled' });
return $('<td />').append(select);
},

buildCol3: function() {
var select = $('<input />', { className: 'col3' });
return $('<td />').append($('<input />', { className: 'col3', disabled: 'disabled' }));
},

buildCol4: function() {
var img = $('<img />', {
src: '/admin_data/public/images/no.png'
});

return $('<td />').append($('<a />', {
text: '',
href: '#',
className: 'remove_row'
}).append(img));
},

buildRow: function() {

var $tr = $('<tr />'),
currentRowNumber = $(document).data('currentRowNumber'),
that = this,
build_array = ['buildCol1', 'buildCol2', 'buildCol3', 'buildCol4'];

if (currentRowNumber === undefined) {
currentRowNumber = 1;
$(document).data('currentRowNumber', currentRowNumber);
} else {
currentRowNumber = parseInt(currentRowNumber, 10) + 1;
$(document).data('currentRowNumber', currentRowNumber);
}

$.each(build_array, function(index, value) {
$tr.append(that[value]());
});

$tr.find('select.col1').attr({ name: 'adv_search[' + currentRowNumber + '_row][col1]' });
$tr.find('select.col2').attr({ name: 'adv_search[' + currentRowNumber + '_row][col2]' });
$tr.find('input.col3').attr({ name: 'adv_search[' + currentRowNumber + '_row][col3]' });

$tr.find('.remove_row').attr('id', 'remove_row_'+currentRowNumber);

return $tr;
}

};
79 changes: 79 additions & 0 deletions app/assets/javascripts/advance_search/advance_search_structure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
AdminData = AdminData || {};

AdminData.mappings = {

//JSLint complains if a hash has key named boolean. So I am changing the key to booleant
booleant: {
options: [
["is null", "is_null"],
["is not null", "is_not_null"],
["is true", "is_true"],
["is false", "is_false"]
]
},

string: {
options: [
["is null", "is_null"],
["is not null", "is_not_null"],
["contains", "contains"],
["is exactly", "is_exactly"],
["doesn't contain", "does_not_contain"]
]
},

text: {
options: [
["is null", "is_null"],
["is not null", "is_not_null"],
["Contains", "contains"],
["Doesn't Contain", "does_not_contain"]
]
},

datetime: {
options: [
["is null", "is_null"],
["is not null", "is_not_null"],
['on', "is_on"],
['on or before', "is_on_or_before_date"],
['on or after', "is_on_or_after_date"]
]
},

date: {
options: [
["is null", "is_null"],
["is not null", "is_not_null"],
['on', "is_on"],
['on or before', "is_on_or_before_date"],
['on or after', "is_on_or_after_date"]
]
},

time: {
options: [
["is null", "is_null"],
["is not null", "is_not_null"],
["is exactly", "is_exactly"]
]
},

decimal: {
options: [
['is equal to', "is_equal_to"],
['is less than', "less_than"],
['is greater than', "greater_than"]
]
},

integer: {
options: [
['is equal to', "is_equal_to"],
['is less than', "less_than"],
['is greater than', "greater_than"]
]
}
};


28 changes: 28 additions & 0 deletions app/assets/javascripts/advance_search/ajaxify_advance_search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var AdminData = AdminData || {};

AdminData.ajaxifyAdvanceSearch = {
successCallback: function(responseText) {
$('#results').html(responseText);
},

beforeSubmitCallback: function(formArray, jqForm) {
$('#results').html('<span class="searching_message">searching...</span>');
$('#advance_search_form').data('admin_data_form_array', formArray);
}
};

$(function() {

var options = {
success: function(responseText) {
AdminData.ajaxifyAdvanceSearch.successCallback(responseText);
},
beforeSubmit: function(formArray, jqForm) {
AdminData.ajaxifyAdvanceSearch.beforeSubmitCallback(formArray, jqForm);
}
};

$('#advance_search_form').ajaxForm(options);

});

8 changes: 8 additions & 0 deletions app/assets/javascripts/advance_search/build_first_row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$(function() {

var json = $.parseJSON( $('#primary_column_type_info').html());
$('#advance_search_table').data('table_structure', json);
AdminData.advanceSearch.buildFirstRow();

});

76 changes: 76 additions & 0 deletions app/assets/javascripts/advance_search/event_bindings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
var AdminData = AdminData || {};

AdminData.bindings = {

col2_change: function(e) {
var arrayList = ['is_false', 'is_true', 'is_null', 'is_not_null'],
$col2 = $(e.target).closest('select'),
value = $col2.val(),
tableStructure = $('#advance_search_table').data('table_structure'),
$col3 = $col2.parents('tr').find('td input.col3'),
$col1 = $col2.parents('tr').find('td select.col1'),
col1ColumnType = tableStructure[$col1.val()];


if (value.length === 0 || ($.inArray(value, arrayList) > - 1)) {
$col3.val('').attr('disabled','disabled');

} else {
$col3.removeAttr('disabled');
if (col1ColumnType === 'datetime' || col1ColumnType === 'date') {
$col3.val(AdminData.jsUtil.dateToString(new Date())).addClass('datepicker');

$('.datepicker').datepicker({ dateFormat: 'dd-MM-yy', changeYear: true, changeMonth: true });

} else {
$('.datepicker').datepicker('destroy');
$col3.removeClass('datepicker').focus(); // do not create focus for date pickers
}
}
},

pagination_click: function(e) {
var href = $(e.target).closest('a').attr('href');

$.ajax({ url: href, dataType: "text", success: function(responseText){
$('#results').html(responseText);
}});

AdminData.jsUtil.colorizeRows();
},

col1_change: function(e) {
var col1 = $(e.target).closest('select'),
tableStructure = $('#advance_search_table').data('table_structure'),
columnType = tableStructure[col1.val()],
options = AdminData.mappings[columnType]['options'],
col2 = col1.parents('tr').find('td select.col2');

col2.html('');
AdminData.jsUtil.buildOptionsFromArray(options, col2);
col2.trigger('change').removeAttr('disabled');
}
};

$('.pagination a').live('click', function(e) {
AdminData.bindings.pagination_click(e);
return false;
});

$('#advance_search_table a.add_row_link').live('click', function() {
$('#advance_search_table').append(AdminData.advanceSearch.buildRow());
return false;
});

$('#advance_search_table a.remove_row').live('click', function(e) {
$(e.target).closest('tr').remove();
return false;
});

$('#advance_search_table select.col1').live('change', function(e) {
AdminData.bindings.col1_change(e);
});

$('#advance_search_table select.col2').live('change', function(e) {
AdminData.bindings.col2_change(e);
});
10 changes: 10 additions & 0 deletions app/assets/javascripts/advance_search/global_ajax_setting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$(function() {

$.ajaxSetup({
'beforeSend': function(xhr) {
xhr.setRequestHeader("Accept", "text/javascript");
}
});

});

14 changes: 14 additions & 0 deletions app/assets/javascripts/advance_search/sortby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$(function(){

var form = $('#advance_search_form');

if (form.length === 0) return;

$('#view_table tr.thead').live('click', function(e){
var value = $(e.target).closest('.sortable').attr('data-sortby');
$('#advance_search_sortby').val(value);
form.submit();
return false;
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$(function() {

$('#advance_search_form').trigger('submit');

});

7 changes: 7 additions & 0 deletions app/assets/javascripts/analytics/report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$(function(){

$('input[name=report_type]').change(function(){
window.location = $(this).val();
});

});
8 changes: 8 additions & 0 deletions app/assets/javascripts/misc/drop_down_change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$(function() {

$('.drop_down_value_klass').change(function() {
window.location = $(this).val();
});

});

Loading

0 comments on commit fcd8e84

Please sign in to comment.