Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

get rid of non needed data

  • Loading branch information...
commit 104afbfdf4d967e1946ce0aab83b2776dbac6611 1 parent fcd8e84
@neerajdotname neerajdotname authored
Showing with 1 addition and 11,767 deletions.
  1. +1 −1  app/controllers/admin_data/public_controller.rb
  2. BIN  lib/public/images/add.png
  3. BIN  lib/public/images/no.png
  4. BIN  lib/public/images/site.png
  5. BIN  lib/public/images/sort_by_asc.jpg
  6. BIN  lib/public/images/sort_by_desc.jpg
  7. BIN  lib/public/images/sort_by_nothing.jpg
  8. +0 −45 lib/public/javascripts/advance_search/act_on_result.js
  9. +0 −83 lib/public/javascripts/advance_search/advance_search.js
  10. +0 −79 lib/public/javascripts/advance_search/advance_search_structure.js
  11. +0 −28 lib/public/javascripts/advance_search/ajaxify_advance_search.js
  12. +0 −8 lib/public/javascripts/advance_search/build_first_row.js
  13. +0 −76 lib/public/javascripts/advance_search/event_bindings.js
  14. +0 −10 lib/public/javascripts/advance_search/global_ajax_setting.js
  15. +0 −14 lib/public/javascripts/advance_search/sortby.js
  16. +0 −6 lib/public/javascripts/advance_search/trigger_submit_on_domready.js
  17. +0 −7 lib/public/javascripts/analytics/report.js
  18. +0 −8 lib/public/javascripts/misc/drop_down_change.js
  19. +0 −58 lib/public/javascripts/misc/js_util.js
  20. +0 −6 lib/public/javascripts/misc/quick_search_input_focus.js
  21. +0 −120 lib/public/javascripts/test/act_on_result.js
  22. +0 −80 lib/public/javascripts/test/advance_search.js
  23. +0 −29 lib/public/javascripts/test/ajaxify_advance_search.js
  24. +0 −10 lib/public/javascripts/test/build_first_row.js
  25. +0 −100 lib/public/javascripts/test/event_bindings.js
  26. +0 −903 lib/public/javascripts/vendor/jack.js
  27. +0 −6,240 lib/public/javascripts/vendor/jquery-1.4.2.js
  28. +0 −298 lib/public/javascripts/vendor/jquery-ui-1.7.2.custom.min.js
  29. +0 −21 lib/public/javascripts/vendor/jquery.ba-isjquery.js
  30. +0 −814 lib/public/javascripts/vendor/jquery_form.js
  31. +0 −9 lib/public/javascripts/vendor/log.js
  32. +0 −1,043 lib/public/javascripts/vendor/qunit.js
  33. +0 −132 lib/public/javascripts/vendor/rails.js
  34. +0 −1,133 lib/public/stylesheets/base.css
  35. +0 −406 lib/public/stylesheets/vendor/jquery-ui-1.7.2.custom.css
View
2  app/controllers/admin_data/public_controller.rb
@@ -2,7 +2,7 @@ module AdminData
class PublicController < ApplicationController
def serve
- path = File.join(AdminData::LIBPATH, 'public', params[:file])
+ path = File.join(AdminData::LIBPATH, '..', 'app', 'assets', params[:file])
unless File.expand_path(path) =~ /admin_data/
render :nothing => true, :status => 404 and return
View
BIN  lib/public/images/add.png
Deleted file not rendered
View
BIN  lib/public/images/no.png
Deleted file not rendered
View
BIN  lib/public/images/site.png
Deleted file not rendered
View
BIN  lib/public/images/sort_by_asc.jpg
Deleted file not rendered
View
BIN  lib/public/images/sort_by_desc.jpg
Deleted file not rendered
View
BIN  lib/public/images/sort_by_nothing.jpg
Deleted file not rendered
View
45 lib/public/javascripts/advance_search/act_on_result.js
@@ -1,45 +0,0 @@
-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;
-});
View
83 lib/public/javascripts/advance_search/advance_search.js
@@ -1,83 +0,0 @@
-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;
- }
-
-};
View
79 lib/public/javascripts/advance_search/advance_search_structure.js
@@ -1,79 +0,0 @@
-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"]
- ]
- }
-};
-
-
View
28 lib/public/javascripts/advance_search/ajaxify_advance_search.js
@@ -1,28 +0,0 @@
-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);
-
-});
-
View
8 lib/public/javascripts/advance_search/build_first_row.js
@@ -1,8 +0,0 @@
-$(function() {
-
- var json = $.parseJSON( $('#primary_column_type_info').html());
- $('#advance_search_table').data('table_structure', json);
- AdminData.advanceSearch.buildFirstRow();
-
-});
-
View
76 lib/public/javascripts/advance_search/event_bindings.js
@@ -1,76 +0,0 @@
-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);
-});
View
10 lib/public/javascripts/advance_search/global_ajax_setting.js
@@ -1,10 +0,0 @@
-$(function() {
-
- $.ajaxSetup({
- 'beforeSend': function(xhr) {
- xhr.setRequestHeader("Accept", "text/javascript");
- }
- });
-
-});
-
View
14 lib/public/javascripts/advance_search/sortby.js
@@ -1,14 +0,0 @@
-$(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;
- });
-
-});
View
6 lib/public/javascripts/advance_search/trigger_submit_on_domready.js
@@ -1,6 +0,0 @@
-$(function() {
-
- $('#advance_search_form').trigger('submit');
-
-});
-
View
7 lib/public/javascripts/analytics/report.js
@@ -1,7 +0,0 @@
-$(function(){
-
- $('input[name=report_type]').change(function(){
- window.location = $(this).val();
- });
-
-});
View
8 lib/public/javascripts/misc/drop_down_change.js
@@ -1,8 +0,0 @@
-$(function() {
-
- $('.drop_down_value_klass').change(function() {
- window.location = $(this).val();
- });
-
-});
-
View
58 lib/public/javascripts/misc/js_util.js
@@ -1,58 +0,0 @@
-var AdminData = AdminData || {};
-
-/**
- * A general Utility
- * @namespace AdminData
- * @class jsUtil
- */
-AdminData.jsUtil = {
-
- // TODO since advance search was not working with util confirm , window.confirm is used directly
- // fix it later
- confirm: function(arg) {
- window.confirm(arg);
- },
-
- buildOptionsFromArray: function(array, element) {
- element.append($('<option />'));
- for (i in array) {
- $('<option />').text(array[i][0]).attr('value', array[i][1]).appendTo(element);
- }
- element.attr('disabled', false);
- },
-
- colorizeRows: function() {
- $('.colorize tr:odd').addClass('odd');
- $('.colorize tr:even').addClass('even');
- },
-
- /**
- * Returns the input date in string format.
- *
- * @param {date} input date
- * @return {string} The string value of input date
- */
- dateToString: function(date) {
- var month = (date.getMonth() + 1).toString();
- var day = date.getDate().toString();
- //days between 1 and 9 should have 0 before them
- if (day.length == 1) day = '0' + day;
- var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
- return day + "-" + months[month - 1] + "-" + date.getFullYear();
- },
-
- /**
- * Generate a random number between 1 and 10000000
- *
- * @return {Integer} a random Integer
- *
- */
- randomNumber: function() {
- var maxVal = 100000000,
- minVal = 1;
- var randVal = minVal + (Math.random() * (maxVal - minVal));
- return Math.round(randVal);
- }
-
-};
-
View
6 lib/public/javascripts/misc/quick_search_input_focus.js
@@ -1,6 +0,0 @@
-$(function() {
-
- $('#quick_search_input').focus();
-
-});
-
View
120 lib/public/javascripts/test/act_on_result.js
@@ -1,120 +0,0 @@
-module('act_on_result', {
- teardown: function() {
- $('#advance_search_delete_all').remove();
- $('#advance_search_destroy_all').remove();
- $('#results').remove();
- $('#advance_search_form').remove();
- },
- setup: function() {
- $(document.body).append($('<a />', {
- href: '#',
- id: 'advance_search_delete_all'
- }));
-
- $(document.body).append($('<a />', {
- href: '#',
- id: 'advance_search_destroy_all'
- }));
-
- $(document.body).append($('<div />', {
- id: 'results'
- }));
-
- $(document.body).append($('<div />', {
- id: 'advance_search_form'
- }));
- }
-});
-
-test('invoking success callback', function() {
- expect(1);
- AdminData.actOnResult.successCallback({
- success: 'hello world'
- });
- equals('hello world', $('#results').text(), '#results should have text hello world');
-});
-
-test('live clicking #advance_search_delete_all with cancel action', function() {
- expect(0);
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return false;
- });
- //TODO ensure that the value passed to action is delete
- jack.expect('AdminData.actOnResult.action').exactly('0 time');
- $('#advance_search_delete_all').trigger('click');
- });
-});
-
-test('live clicking #advance_search_delete_all', function() {
- expect(0);
- var args;
-
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return true;
- });
- jack.expect('AdminData.actOnResult.action').once().mock(function(action_type) {
- args = action_type;
- return {};
- });
- $('#advance_search_delete_all').trigger('click');
- });
- equals('delete', args, 'action_type should be delete');
-
-});
-
-test('live clicking #advance_search_destroy_all with cancel action', function() {
- expect(0);
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return false;
- });
- jack.expect('AdminData.actOnResult.action').exactly('0 time');
- $('#advance_search_destroy_all').trigger('click');
- });
-});
-
-test('live clicking #advance_search_destroy_all', function() {
- expect(0);
- var args;
-
- jack(function() {
- jack.expect('AdminData.jsUtil.confirm').once().mock(function() {
- return true;
- });
- jack.expect('AdminData.actOnResult.action').once().mock(function(action_type) {
- args = action_type;
- return {};
- });
- $('#advance_search_destroy_all').trigger('click');
- });
- equals('destroy', args, 'action_type should be destroy');
-});
-
-test('actOnResultAJAX', function() {
- expect(5);
- $('#advance_search_form').attr('action', 'http://localhost:3000');
- $('#advance_search_form').data('admin_data_form_array', [{
- name: 'foo',
- value: 'i_am_foo'
- }]);
-
- var ajaxArgs;
-
- jack(function() {
- jack.expect('$.ajax').once().mock(function(args) {
- ajaxArgs = args;
- });
- AdminData.actOnResult.action('delete');
- });
-
- equals('post', ajaxArgs.type, 'ajax arguments should have type as post');
- equals('json', ajaxArgs.dataType, 'ajax arguments should have json as dataType');
- equals('http://localhost:3000', ajaxArgs.url, 'ajax arguments should have valid url');
- var data = ajaxArgs.data;
- ok(data, 'ajax arguments should have value for key data');
- equals('foo=i_am_foo&admin_data_advance_search_action_type=delete', data, 'data should have parameterized value');
-
-});
-
View
80 lib/public/javascripts/test/advance_search.js
@@ -1,80 +0,0 @@
-module('advance_search');
-
-test('buildFirstRow', function() {
- expect(2);
- $('#advance_search_table').html('');
- AdminData.advanceSearch.buildFirstRow();
- var $a = $('#advance_search_table').find('a');
- ok($a.hasClass('add_row_link'), 'first row should have anchor element with class remove_row');
- ok('+', $a.text(), 'first row should have anchor element with text +');
-});
-
-
-test("buildCol1", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol1();
- ok($.isjQuery($td), "buildCol1 should return an instance of jQuery");
-
- var className = $td.find('select').attr('className');
- equals('col1', className, 'buildCol1 should have select with class col1');
-
- var countOfOptions = $td.find('select option').length;
- equals(12, countOfOptions, 'buildCol1 should have select with 12 options');
-});
-
-test("buildCol2", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol2();
- ok($.isjQuery($td), "buildCol2 should return an instance of jQuery");
-
- ok($td.find('select').hasClass('col2'), 'buildCol2 should have class col2');
- ok($td.find('select').hasClass('disabled'), 'buildCol2 should have class disabled');
-});
-
-test("buildCol3", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol3();
- ok($.isjQuery($td), "buildCol3 should return an instance of jQuery");
-
- ok($td.find('input').hasClass('col3'), 'buildCol3 should have input element with class col3');
- ok($td.find('input').attr('disabled'), 'buildCol3 should have input element with attribute disabled');
-});
-
-test("buildCol4", function() {
- expect(3);
-
- var $td = AdminData.advanceSearch.buildCol4();
- ok($.isjQuery($td), "buildCol4 should return an instance of jQuery");
-
- var a = $td.find('a');
- ok(a.hasClass('remove_row'), 'buildCol4 should have anchor element with class remove_row');
- equals('x', a.text(), 'buildCol4 should have anchor element with text x');
-});
-
-test("buildRow", function() {
- expect(8);
- jack(function() {
- jack.expect("AdminData.jsUtil.randomNumber").exactly("1 time").mock(function() {
- return 100;
- });
-
- var $tr = AdminData.advanceSearch.buildRow();
- ok($.isjQuery($tr), "buildCol4 should return an instance of jQuery");
-
- equals(4, $tr.find('td').length, 'buildRow should have 4 td elements');
-
- ok($tr.find('select.col1').attr('name'), 'buildRow should have select.col1 with attribute name');
- ok($tr.find('select.col2').attr('name'), 'buildRow should have select.col1 with attribute name');
- ok($tr.find('input.col3').attr('name'), 'buildRow should have input.col1 with attribute name');
-
- equals('adv_search[100_row][col1]', $tr.find('select.col1').attr('name'), 'select.col1 should have right name');
- equals('adv_search[100_row][col2]', $tr.find('select.col2').attr('name'), 'select.col2 should have right name');
- equals('adv_search[100_row][col3]', $tr.find('input.col3').attr('name'), 'input.col3 should have right name');
-
- });
-
-});
-
View
29 lib/public/javascripts/test/ajaxify_advance_search.js
@@ -1,29 +0,0 @@
-module('ajaxify advance search', {
- teardown: function() {
- $('#results').remove();
- $('#advance_search_form').remove();
- },
- setup: function() {
- $(document.body).append($('<div />', {
- id: 'results'
- }));
- $(document.body).append($('<div />', {
- id: 'advance_search_form'
- }));
- }
-});
-
-test('successCallback', function() {
- expect(1);
- AdminData.ajaxifyAdvanceSearch.successCallback('hello world');
- equals('hello world', $('#results').text(), '#results should have text hello world');
-});
-
-test('beforeSubmitCallback', function() {
- expect(1);
- AdminData.ajaxifyAdvanceSearch.beforeSubmitCallback(['1', '2'], null);
-
- var $results = $('#results');
- equals('searching...', $('#results').text(), '#results should have text searching');
-});
-
View
10 lib/public/javascripts/test/build_first_row.js
@@ -1,10 +0,0 @@
-module('build_first_row');
-
-test('table structure', function() {
- expect(1);
-
- var tableStructure = $('#advance_search_table').data('table_structure');
- ok(tableStructure, 'tableStructure should not be blank');
-
-});
-
View
100 lib/public/javascripts/test/event_bindings.js
@@ -1,100 +0,0 @@
-module('event_bindings');
-
-test('live click on a.add_row_link', function() {
- expect(3);
-
- $('#advance_search_table').html('');
- equals(0, $('#advance_search_table tr').length, 'there should be no row in the table');
-
- AdminData.advanceSearch.buildFirstRow();
- equals(1, $('#advance_search_table tr').length, 'there should be only first row in the table');
-
- $('#advance_search_table a.add_row_link').trigger('click');
- equals(2, $('#advance_search_table tr').length, 'additional row should be added to the table');
-});
-
-test('live click on a.remove_row link', function() {
- expect(5);
-
- $('#advance_search_table').html('');
- equals(0, $('#advance_search_table tr').length, 'there should be no row in the table');
-
- AdminData.advanceSearch.buildFirstRow();
- equals(1, $('#advance_search_table tr').length, 'there should be only first row in the table');
-
- $('#advance_search_table').append(AdminData.advanceSearch.buildRow());
- equals(2, $('#advance_search_table tr').length, 'there should be two rows in the table');
-
- var $a = $('#advance_search_table a.remove_row');
- equals(1, $a.length, 'there should be one anchor element with class remove_row');
-
- $('#advance_search_table a.remove_row').trigger('click');
- equals(1, $('#advance_search_table tr').length, 'there should be only one row in the table');
-});
-
-test('live select.col1 change', function() {
- expect(10);
-
- $('#advance_search_table').html('');
- equals(0, $('#advance_search_table tr').length, 'there should be no row in the table');
-
- AdminData.advanceSearch.buildFirstRow();
- equals(1, $('#advance_search_table tr').length, 'there should be only first row in the table');
-
- ok($('#advance_search_table select.col2').is(':disabled'), 'second column should be disabled');
-
- $('#advance_search_table select.col1').val('first_name');
- $('#advance_search_table select.col1').trigger('change');
-
- ok(!$('#advance_search_table select.col2').is(':disabled'), 'second column should be enabled');
-
- var s = $('#advance_search_table select.col2 option').eq(0).text();
- equals('', s, 'empty value should be the first option');
-
- s = $('#advance_search_table select.col2 option').eq(1).text();
- equals('is null', s, 'is null should be the second option');
-
- s = $('#advance_search_table select.col2 option').eq(2).text();
- equals('is not null', s, 'is null should be the third option');
-
- s = $('#advance_search_table select.col2 option').eq(3).text();
- equals('contains', s, 'contains should be the fourth option');
-
- s = $('#advance_search_table select.col2 option').eq(4).text();
- equals('is exactly', s, 'contains should be the fifth option');
-
- s = $('#advance_search_table select.col2 option').eq(5).text();
- equals("doesn't contain", s, 'does not contain should be the sixth option');
-});
-
-test('live select.col2 change', function() {
- expect(2);
-
- $('#advance_search_table').html('');
- AdminData.advanceSearch.buildFirstRow();
- ok($('#advance_search_table input.col3').is(':disabled'), 'third column should be disabled');
-
- $('#advance_search_table select.col1').val('first_name');
- $('#advance_search_table select.col1').trigger('change');
- $('#advance_search_table select.col2').val('contains');
- $('#advance_search_table select.col2').trigger('change');
-
- ok($('#advance_search_table input.col3').is(':enabled'), 'third column should be enabled');
-});
-
-
-test('live select.col2 change for is_null input', function() {
- expect(2);
-
- $('#advance_search_table').html('');
- AdminData.advanceSearch.buildFirstRow();
- ok($('#advance_search_table input.col3').is(':disabled'), 'third column should be disabled');
-
- $('#advance_search_table select.col1').val('first_name');
- $('#advance_search_table select.col1').trigger('change');
- $('#advance_search_table select.col2').val('is_null');
- $('#advance_search_table select.col2').trigger('change');
-
- ok($('#advance_search_table input.col3').is(':disabled'), 'third column should be disabled');
-});
-
View
903 lib/public/javascripts/vendor/jack.js
@@ -1,903 +0,0 @@
-/**
- *
- * JACK :: JavaScript Mocking.
- * Version: $Id$
- *
- */
-
-
-function jack() {} // This needs to be here to make error reporting work correctly in IE.
-
-(function (){ // START HIDING FROM GLOBAL SCOPE
- /** EXPORT JACK **/
- window.jack = new Jack();
- window.jack.matchers = new Matchers();
- window.jack.util = new Util();
- window.jack.FunctionSpecification = FunctionSpecification;
- window.jack.FunctionGrab = FunctionGrab;
- return;
-
-
- /**
- * Constructor for object that will be exposed as the global jack
- */
- function Jack() {
- var functionGrabs = {};
- var objectGrabs = {};
- var environment = new Environment();
- var reportMessages = [];
- var currentExpectation = null;
- var publicApi = createPublicApi();
- return publicApi;
-
- function createPublicApi() {
- var api = jackFunction;
- api.grab = grab;
- api.create = create;
- api.inspect = inspect;
- api.expect = expect;
- api.verify = verify;
- api.report = report;
- api.reportAll = reportAll;
- api.env = environment;
- return api;
- }
- function jackFunction(delegate) {
- before();
- firstPass(delegate);
- // secondPass(delegate);
- after();
- }
- function before() {
- functionGrabs = {};
- objectGrabs = {};
- environment.reset();
- }
- function firstPass(delegate) {
- delegate();
- }
- function secondPass(delegate) {
- var oldExpect = publicApi.expect;
- publicApi.expect = function(name) {
- var fakeEx = {};
- var grab = findGrab(name);
- if(grab._beenThroughSecondPass) {
- var ex = grab.expect();
- for(prop in ex) {
- if(typeof ex[prop] == "function") {
- fakeEx[prop] = function() { return fakeEx; }
- }
- }
- }
- grab._beenThroughSecondPass = true;
- return fakeEx;
- };
- var findMore = true;
- for(var i=0; findMore && i<10; i++) {
- try {
- delegate();
- findMore = false;
- } catch(exception) {
- var line = -1;
- if(exception.lineNumber != null) {
- line = exception.lineNumber;
- } else if(exception['opera#sourceloc'] != null) {
- line = exception['opera#sourceloc'];
- }
- currentExpectation._lineNumber = line;
- }
- }
- publicApi.expect = oldExpect;
- }
- function after() {
- var reports = getTextReports();
- resetGrabs();
- if(reports.length > 0) {
- environment.report(reports[0]);
- }
- }
- function getTextReports() {
- var failedReports = [];
- for(var name in functionGrabs) {
- var reports = functionGrabs[name].reportAll(name);
- for(var i=0; i<reports.length; i++) {
- if(reports[i].fail) {
- failedReports.push(reports[i].message);
- }
- }
- }
- for(var name in objectGrabs) {
- var reports = objectGrabs[name].report(name);
- for(var i=0; i<reports.length; i++) {
- if(reports[i].fail) {
- failedReports.push(reports[i].message);
- }
- }
- }
- return failedReports;
- }
- function grab() {
- if("object" == typeof arguments[0] && "string" == typeof arguments[1]) {
- var parentObject = arguments[0];
- var name = arguments[1];
- var fullName = "[local]." + name;
- return grabFunction(fullName, parentObject[name], parentObject);
- } else {
- var grabbed = null;
- eval("grabbed = " + arguments[0]);
- if("function" == typeof grabbed) {
- var functionGrab = grabFunction(arguments[0], grabbed);
- eval("grabbed = " + arguments[0]);
- grabObject(arguments[0], grabbed);
- return functionGrab;
- } else if("object" == typeof grabbed) {
- return grabObject(arguments[0], grabbed);
- }
- return null;
- }
- }
- function grabFunction(fullName, grabbed, parentObject) {
- if(parentObject == null) {
- parentObject = window;
- }
- var functionName = fullName;
- var nameParts = fullName.split(".");
- if(nameParts[0] == "[local]") {
- functionName = nameParts[1];
- } else if(nameParts.length > 1) {
- functionName = nameParts.pop();
- if(parentObject == window) {
- var parentName = nameParts.join(".");
- eval("parentObject = " + parentName);
- }
- }
- functionGrabs[fullName] = new FunctionGrab(functionName, grabbed, parentObject);
- return functionGrabs[fullName];
- }
- function grabObject(name, grabbed) {
- objectGrabs[name] = new ObjectGrab(name, grabbed);
- return objectGrabs[name];
- }
- function create(objectName, functionNames) {
- var mockObject = {};
- for(var i=0; i<functionNames.length; i++) {
- mockObject[functionNames[i]] = function() {};
- var fullName = objectName+"."+functionNames[i];
- grabFunction(fullName, mockObject[functionNames[i]], mockObject);
- }
- return mockObject;
- }
- function inspect(name) {
- return findGrab(name);
- }
- function expect(name) {
- if(findGrab(name) == null) {
- grab(name);
- }
- currentExpectation = findGrab(name).expect().once();
- return currentExpectation;
- }
- function verify(name) {
- if(findGrab(name) == null) {
- grab(name);
- }
- currentExpectation = findGrab(name).expect().once();
- return currentExpectation;
- }
- function report(name, expectation) {
- return findGrab(name).report(expectation, name);
- }
- function reportAll(name) {
- return findGrab(name).reportAll(name);
- }
- function findGrab(name) {
- var parts = name.split(".");
- if(parts.length == 1 && functionGrabs[name] != null) {
- return functionGrabs[name];
- } else if(parts.length == 1 && objectGrabs[name] != null) {
- return objectGrabs[name];
- } else {
- if(functionGrabs[name] != null) {
- return functionGrabs[name];
- }
- if(objectGrabs[name] != null) {
- return objectGrabs[name];
- }
- if(objectGrabs[parts[0]] != null) {
- return objectGrabs[parts[0]].examine(parts[1]);
- }
- return undefined;
- }
- }
- function resetGrabs() {
- for(var g in functionGrabs) {
- functionGrabs[g].reset();
- }
- for(var g in objectGrabs) {
- objectGrabs[g].reset();
- }
- }
- } // END Jack()
-
-
- /**
- * @functionName Name of grabbed function
- * @grabbedFunction Reference to grabbed function
- * @parentObject The object the function was grabbed from
- */
- function FunctionGrab(functionName, grabbedFunction, parentObject) {
- var invocations = [];
- var specifications = [];
- var emptyFunction = function(){};
-
- init();
- return {
- 'times': function() { return invocations.length; },
- 'reset': reset,
- 'expect': expect,
- 'specify': specify,
- 'report': report,
- 'reportAll': reportAll,
- 'mock': mock,
- 'stub': stub,
- 'arguments': getArguments,
- 'name': function() { return functionName }
- };
-
- function init() {
- var original = parentObject[functionName];
- var handler = function() {
- return handleInvocation.apply(this,arguments);
- }
- for(var prop in original) {
- handler[prop] = original[prop];
- }
- parentObject[functionName] = handler;
- }
- function handleInvocation() {
- var invocation = new FunctionSpecification();
- for(var i=0; i<arguments.length; i++) {
- invocation.whereArgument(i).is(arguments[i]);
- }
- invocations.push(invocation);
- var specification = findSpecificationFor(invocation);
- if(specification == null) {
- return grabbedFunction.apply(this, arguments);
- } else if(specification.hasMockImplementation()) {
- return specification.invoke.apply(this, arguments);
- } else {
- specification.invoke.apply(this, arguments);
- return grabbedFunction.apply(this, arguments);
- }
- }
- function matchInvocationsToSpecifications() {
- for(var i=0; i<invocations.length; i++) {
- var spec = findSpecificationFor(invocations[i]);
- if(spec != null) {
-
- }
- }
- }
- function findSpecificationFor(invocation) {
- for(var i=0; i<specifications.length; i++) {
- var specification = specifications[i];
- if(invocation.satisfies(specification)) {
- return specification;
- }
- }
- return null;
- }
- function isArgumentContstraintsMatching(invocation, expectation) {
- var constr = expectation._argumentConstraints;
- var arg = invocation.arguments;
- if(constr == null) {
- return true;
- } else if(constr.length != arg.length) {
- return false;
- } else {
- for(var i=0; i<constr.length; i++) {
- if(!constr[i]) { continue; }
- for(var j=0; j<constr[i].length; j++) {
- if(typeof constr[i][j] == "function" && !constr[i][j](arg[i])) {
- return false;
- }
- }
- }
- return true;
- }
- }
- function reset() {
- parentObject[functionName] = grabbedFunction;
- }
- function specify() {
- var spec = new FunctionSpecification();
- spec._id = specifications.length;
- specifications.push(spec);
- return spec;
- }
- function verify() {
-
- }
- function expect() {
- return specify();
- }
- function mock(implementation) {
- return expect().mock(implementation);
- }
- function stub() {
- return expect();
- }
- function parseTimes(expression) {
- var result = 0;
- if("number" == typeof expression) {
- result = expression;
- } else if("string" == typeof expression) {
- var parts = expression.split(" ");
- result = parseInt(parts[0]);
- }
- return result;
- }
- function reportAll(fullName) {
- var reports = [];
- for(var i=0; i<specifications.length; i++) {
- reports.push(report(specifications[i], fullName));
- }
- return reports;
- }
- function report(specification, fullName) {
- if(specification == null) {
- if(specifications.length == 0) {
- var spec = specify().never();
- for(var i=0; i<invocations.length; i++) {
- spec.invoke();
- }
- }
- specification = specifications[0];
- }
- var report = {};
- report.expected = specification.invocations().expected;
- report.actual = specification.invocations().actual;
- report.success = specification.testTimes(report.actual);
- report.fail = !report.success;
- if(report.fail) {
- report.message = "Expectation failed: " + specification.describe(fullName);
- }
- return report;
- }
- function generateReportMessage(report, fullName, argumentsDisplay) {
- return report.messageParts.template
- .replace("{name}",fullName)
- .replace("{arguments}",argumentsDisplay)
- .replace("{quantifier}",report.messageParts.quantifier)
- .replace("{expected}",report.expected)
- .replace("{actual}",report.actual);
- }
- function getArgumentsDisplay(expectation) {
- if(expectation == null) {
- return "";
- }
- var displayValues = [];
- var constraints = expectation._argumentConstraints;
- if(constraints == null) {
- return "";
- } else {
- for(var i=0; i<constraints.length; i++) {
- if(constraints[i] != null) {
- displayValues.push(constraints[i][0].display);
- } else {
- displayValues.push('[any]');
- }
- }
- return displayValues.join(', ');
- }
- }
- function getArguments() {
- return invocations[0].getArgumentValues();
- }
- } // END FunctionGrab()
-
-
- /**
- *
- */
- function ObjectGrab(objectName, grabbedObject) {
- var grabs = {};
-
- init();
- return {
- 'examine': getGrab,
- 'report': report,
- 'getGrab': getGrab,
- 'getGrabs': function() { return grabs },
- 'reset': reset
- };
-
- function init() {
- for(key in grabbedObject) {
- var property = grabbedObject[key];
- if("function" == typeof property) {
- grabs[key] = new FunctionGrab(key, property, grabbedObject);
- }
- }
- }
- function report(name) {
- var allReports = [];
- for(var g in grabs) {
- var reports = grabs[g].reportAll(name+"."+grabs[g].name());
- for(var i=0; i<reports.length; i++) {
- allReports.push(reports[i]);
- }
- }
- return allReports;
- }
- function getGrab(name) {
- return grabs[name];
- }
- function reset() {
- for(var g in grabs) {
- grabs[g].reset();
- }
- }
- }
-
-
- /**
- *
- */
- function Environment() {
- var reportingEnabled = true;
- init();
- return {
- 'isJSSpec': isJSSpec,
- 'isScriptaculous': isScriptaculous,
- 'isQunit': isQunit,
- 'isJsTestDriver': isJsTestDriver,
- 'isYuiTest': isYuiTest,
- 'report': report,
- 'disableReporting': function() { reportingEnabled = false; },
- 'enableReporting': function() { reportingEnabled = true; },
- 'reset': function() {}
- }
- function init() {
-
- }
- function isJSSpec() {
- return window.JSSpec != null;
- }
- function isScriptaculous() {
- return window.Test != null && window.Test.Unit != null && window.Test.Unit.Runner != null;
- }
- function isQunit() {
- return window.QUnit != null;
- }
- function isJsTestDriver() {
- return window.jstestdriver != null;
- }
- function isYuiTest() {
- var y = window.YAHOO;
- return y != null && y.tool != null && y.tool.TestCase != null;
- }
- function report(message) {
- if(!reportingEnabled) { return; }
- if(isYuiTest()) {
- YAHOO.util.Assert.fail(message);
- } else if(isJsTestDriver()) {
- fail(message);
- } else if(isScriptaculous()) {
- throw new Error(message);
- } else if(isQunit()) {
- ok(false, message);
- } else if(isJSSpec()) {
- throw new Error(message);
- }
- }
- }
-
- /**
- *
- */
- function Util() {
- return {
- 'displayValue': displayValue
- }
-
- function displayValue() {
- var value = arguments[0];
- var prefix = "";
- if(arguments.length > 1) {
- value = arguments[1];
- prefix = arguments[0];
- }
- if(value == undefined) {
- return displayValueNullOrUndefined(value);
- }
- var display = displayValueDefault(value);
- if('string' == typeof value) {
- display = displayValueString(value);
- } else if(value.constructor == Array) {
- display = displayValueArray(value);
- } else if(value.constructor == RegExp) {
- display = displayValueRegExp(value);
- } else if('object' == typeof value) {
- display = displayValueObject(value);
- }
- return prefix + display;
- }
- function displayValueDefault(value) {
- return value.toString();
- }
- function displayValueString(value) {
- return "'" + value + "'";
- }
- function displayValueArray(value) {
- var displayValues = [];
- for(var i=0; i<value.length; i++) {
- displayValues.push(displayValue(value[i]));
- }
- return "[" + displayValues.join(",") + "]";
- }
- function displayValueNullOrUndefined(value) {
- if(value === undefined) {
- return "undefined";
- } else if(value === null) {
- return "null";
- }
- }
- function displayValueRegExp(value) {
- return value.toString();
- }
- function displayValueObject(value) {
- var keyValues = [];
- for(var p in value) {
- keyValues.push(p + ':' + displayValue(value[p]));
- }
- return '{' + keyValues.join(',') + '}';
- }
- }
-
- /**
- *
- */
- function FunctionSpecification() {
- var constraints = null;
- var argumentValues = [];
- var mockImplementation = null;
- var timing = {actual: 0, expected: 1, modifier: 0};
-
- var api = createApi();
- return api;
-
- function createApi() {
- var api = {};
- mixinMatchers(api);
- mixinTiming(api);
- api.test = test;
- api.testTimes = testTimes;
- api.satisfies = satisfies;
- api.invoke = invoke;
- api.mock = mock;
- api.stub = stub;
- api.returnValue = returnValue;
- api.returnValues = returnValues;
- api.describe = describe;
- api.invocations = invocations;
- api.getArgumentValues = getArgumentValues;
- api.hasMockImplementation = hasMockImplementation;
- return api;
- }
- function mixinMatchers(api) {
- api.whereArgument = function(argIndex) {
- var collected = {};
- for(var name in jack.matchers) {
- addMatcher(argIndex, name, collected)
- }
- return collected;
- }
- api.withArguments = function() {
- for(var i=0; i<arguments.length; i++) {
- api.whereArgument(i).is(arguments[i]);
- }
- return api;
- }
- api.withNoArguments = function() { constraints = []; return api; }
- return api;
-
- function addMatcher(argIndex, name, collection) {
- collection[name] = function() {
- addConstraint(argIndex, jack.matchers[name], arguments);
- if(name == "is") {
- addArgumentValue(argIndex, arguments[0]);
- }
- return api;
- }
- }
- }
- function mixinTiming(api) {
- api.exactly = function(times) {
- timing.expected = parseTimes(times);
- return api;
- }
- api.once = function() {
- timing.expected = 1;
- return api;
- }
- api.atLeast = function(times) {
- timing.expected = parseTimes(times);
- timing.modifier = 1;
- return api;
- }
- api.atMost = function(times) {
- timing.expected = parseTimes(times);
- timing.modifier = -1;
- return api;
- }
- api.never = function() {
- timing.expected = 0;
- return api;
- }
-
- function parseTimes(times) {
- return parseInt(times);
- }
- }
- function addArgumentValue(index, value) {
- argumentValues[index] = value;
- }
- function addConstraint(argIndex, matcher, matcherArguments) {
- createConstraintsArrayIfNull(argIndex);
- var constraint = function(value) {
- var allArguments = [value];
- for(var i=0; i<matcherArguments.length; i++) {
- allArguments.push(matcherArguments[i]);
- }
- var test = matcher.apply(null, allArguments);
- return test.result;
- }
- constraints[argIndex].push(constraint);
- constraints[argIndex].describe = function() {
- var allArguments = [""];
- for(var i=0; i<matcherArguments.length; i++) {
- allArguments.push(matcherArguments[i]);
- }
- return matcher.apply(null, allArguments).expected;
- }
- }
- function createConstraintsArrayIfNull(argIndex) {
- if(constraints == null) {
- constraints = [];
- }
- if(constraints[argIndex] == null) {
- constraints[argIndex] = [];
- }
- }
- function test() {
- var result = true;
- if(constraints != null) {
- if(constraints.length != arguments.length) {
- result = false;
- } else {
- for (var i = 0; i < constraints.length; i++) {
- var oneArgumentsConstraints = constraints[i];
- if (oneArgumentsConstraints != null) {
- for (var j = 0; j < oneArgumentsConstraints.length; j++) {
- var constraint = oneArgumentsConstraints[j];
- if (constraint && !constraint(arguments[i])) {
- result = false;
- }
- }
- }
- }
- }
- }
- return result;
- }
- function testTimes(times) {
- if(timing.modifier == 0) {
- return times == timing.expected;
- } else if(timing.modifier == 1) {
- return times >= timing.expected;
- } else if(timing.modifier == -1) {
- return times <= timing.expected;
- }
- }
- function satisfies(other) {
- return other.test.apply(this, argumentValues);
- }
- function invoke() {
- timing.actual++;
- if(mockImplementation != null) {
- return mockImplementation.apply(this, arguments);
- }
- }
- function mock(implementation) {
- mockImplementation = implementation;
- return api;
- }
- function stub() {
- mockImplementation = function() {};
- return api;
- }
- function returnValue(value) {
- mockImplementation = function() {
- return value;
- }
- }
- function returnValues() {
- var values = [], orig = this;
- for (var i = 0, len = arguments.length; i < len; i++) { values.push(arguments[i]); }
- mockImplementation = function() {
- return values.shift();
- };
- }
- function hasMockImplementation() {
- return mockImplementation != null;
- }
- function invocations() {
- return {
- actual: timing.actual,
- expected: timing.expected
- };
- }
- function getArgumentValues() {
- return argumentValues;
- }
- function describe(name) {
- return name +"(" + describeConstraints() + ") " + describeTimes();
- }
- function describeConstraints() {
- if(constraints == null) {
- return "";
- }
- var descriptions = [];
- for(var i=0; i<constraints.length; i++) {
- if(constraints[i] != null) {
- descriptions.push(constraints[i].describe());
- } else {
- descriptions.push("[any]");
- }
- }
- return descriptions.join(", ");
- }
- function describeTimes() {
- var description = timing.expected;
- if(timing.expected == 1) {
- description += " time";
- } else {
- description += " times";
- }
- if(timing.modifier == 0) {
- description = "expected exactly " + description;
- } else if(timing.modifier > 0) {
- description = "expected at least " + description;
- } else if(timing.modifier < 0) {
- description = "expected at most " + description;
- }
- description += ", called " + timing.actual + " time";
- if(timing.actual != 1) {
- description += "s";
- }
- return description;
- }
- }
-
-
- /**
- *
- */
- function Matchers() {
- return {
- 'is':
- function(a, b) {
- return result(a==b, a, '', b);
- },
- 'isNot':
- function(a, b) {
- return result(a!=b, a, 'not:', b);
- },
- 'isType':
- function(a, b) {
- return result(b == typeof a, a, 'type:', b);
- },
- 'matches':
- function(a, b) {
- return result(b.test(a), a, 'matching:', b)
- },
- 'hasProperty':
- function(a, b, c) {
- var match = c ? a[b]==c : a[b]!=undefined;
- var bDisplay = b;
- if(c != null) {
- bDisplay = {};
- bDisplay[b] = c;
- }
- return result(match, a, 'property:', bDisplay)
- },
- 'hasProperties':
- function(a, b) {
- var match = true;
- for(var p in b) {
- if(a[p] != b[p]) {
- match = false;
- }
- }
- return result(match, a, 'properties:', b);
- },
- 'isGreaterThan':
- function(a, b) {
- return result(b < a, a, '>', b);
- },
- 'isLessThan':
- function(a, b) {
- return result(b > a, a, '<', b);
- },
- 'isOneOf':
- function() {
- var a = arguments[0];
- var b = [];
- for(var i=1; i<arguments.length; i++) {
- b.push(arguments[i]);
- }
- var match = false;
- for(var i=0; i<b.length; i++) {
- if(b[i] == a) {
- match = true;
- }
- }
- return result(match, a, 'oneOf:', b);
- }
- }
-
- function result(match, actual, prefix, expected) {
- return {
- result: match,
- actual: jack.util.displayValue(actual),
- expected: jack.util.displayValue(prefix, expected)
- }
- }
- }
-
-})(); // END HIDING FROM GLOBAL SCOPE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
6,240 lib/public/javascripts/vendor/jquery-1.4.2.js
0 additions, 6,240 deletions not shown
View
298 lib/public/javascripts/vendor/jquery-ui-1.7.2.custom.min.js
0 additions, 298 deletions not shown
View
21 lib/public/javascripts/vendor/jquery.ba-isjquery.js
@@ -1,21 +0,0 @@
-/*!
- * jQuery isjQuery - v0.4 - 2/13/2010
- * http://benalman.com/projects/jquery-misc-plugins/
- *
- * Copyright (c) 2010 "Cowboy" Ben Alman
- * Dual licensed under the MIT and GPL licenses.
- * http://benalman.com/about/license/
- */
-
-// Since every jQuery object has a .jquery property, it's usually safe to test
-// the existence of that property. Of course, this only works as long as you
-// know that any non-jQuery object you might be testing has no .jquery property.
-// So.. what do you do when you need to test an external object whose properties
-// you don't know?
-//
-// If you currently use instanceof, read this Ajaxian article:
-// http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
-
-jQuery.isjQuery = function( obj ){
- return obj && obj.hasOwnProperty && obj instanceof jQuery;
-};
View
814 lib/public/javascripts/vendor/jquery_form.js
@@ -1,814 +0,0 @@
-/*
- *
- * jQuery Form Plugin
- * @requires jQuery v1.1 or later
- *
- * Examples at: http://malsup.com/jquery/form/
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- *
- * Revision: $Id: jquery.form.js 2884 2007-08-24 23:13:55Z malsup $
- */
- (function($) {
-/**
- * ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.
- *
- * ajaxSubmit accepts a single argument which can be either a success callback function
- * or an options Object. If a function is provided it will be invoked upon successful
- * completion of the submit and will be passed the response from the server.
- * If an options Object is provided, the following attributes are supported:
- *
- * target: Identifies the element(s) in the page to be updated with the server response.
- * This value may be specified as a jQuery selection string, a jQuery object,
- * or a DOM element.
- * default value: null
- *
- * url: URL to which the form data will be submitted.
- * default value: value of form's 'action' attribute
- *
- * type: The method in which the form data should be submitted, 'GET' or 'POST'.
- * default value: value of form's 'method' attribute (or 'GET' if none found)
- *
- * beforeSubmit: Callback method to be invoked before the form is submitted.
- * default value: null
- *
- * success: Callback method to be invoked after the form has been successfully submitted
- * and the response has been returned from the server
- * default value: null
- *
- * dataType: Expected dataType of the response. One of: null, 'xml', 'script', or 'json'
- * default value: null
- *
- * semantic: Boolean flag indicating whether data must be submitted in semantic order (slower).
- * default value: false
- *
- * resetForm: Boolean flag indicating whether the form should be reset if the submit is successful
- *
- * clearForm: Boolean flag indicating whether the form should be cleared if the submit is successful
- *
- *
- * The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for
- * validating the form data. If the 'beforeSubmit' callback returns false then the form will
- * not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data
- * in array format, the jQuery object, and the options object passed into ajaxSubmit.
- * The form data array takes the following form:
- *
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
- *
- * If a 'success' callback method is provided it is invoked after the response has been returned
- * from the server. It is passed the responseText or responseXML value (depending on dataType).
- * See jQuery.ajax for further details.
- *
- *
- * The dataType option provides a means for specifying how the server response should be handled.
- * This maps directly to the jQuery.httpData method. The following values are supported:
- *
- * 'xml': if dataType == 'xml' the server response is treated as XML and the 'success'
- * callback method, if specified, will be passed the responseXML value
- * 'json': if dataType == 'json' the server response will be evaluted and passed to
- * the 'success' callback, if specified
- * 'script': if dataType == 'script' the server response is evaluated in the global context
- *
- *
- * Note that it does not make sense to use both the 'target' and 'dataType' options. If both
- * are provided the target will be ignored.
- *
- * The semantic argument can be used to force form serialization in semantic order.
- * This is normally true anyway, unless the form contains input elements of type='image'.
- * If your form must be submitted with name/value pairs in semantic order and your form
- * contains an input of type='image" then pass true for this arg, otherwise pass false
- * (or nothing) to avoid the overhead for this logic.
- *
- *
- * When used on its own, ajaxSubmit() is typically bound to a form's submit event like this:
- *
- * $("#form-id").submit(function() {
- * $(this).ajaxSubmit(options);
- * return false; // cancel conventional submit
- * });
- *
- * When using ajaxForm(), however, this is done for you.
- *
- * @example
- * $('#myForm').ajaxSubmit(function(data) {
- * alert('Form submit succeeded! Server returned: ' + data);
- * });
- * @desc Submit form and alert server response
- *
- *
- * @example
- * var options = {
- * target: '#myTargetDiv'
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc Submit form and update page element with server response
- *
- *
- * @example
- * var options = {
- * success: function(responseText) {
- * alert(responseText);
- * }
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc Submit form and alert the server response
- *
- *
- * @example
- * var options = {
- * beforeSubmit: function(formArray, jqForm) {
- * if (formArray.length == 0) {
- * alert('Please enter data.');
- * return false;
- * }
- * }
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc Pre-submit validation which aborts the submit operation if form data is empty
- *
- *
- * @example
- * var options = {
- * url: myJsonUrl.php,
- * dataType: 'json',
- * success: function(data) {
- * // 'data' is an object representing the the evaluated json data
- * }
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc json data returned and evaluated
- *
- *
- * @example
- * var options = {
- * url: myXmlUrl.php,
- * dataType: 'xml',
- * success: function(responseXML) {
- * // responseXML is XML document object
- * var data = $('myElement', responseXML).text();
- * }
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc XML data returned from server
- *
- *
- * @example
- * var options = {
- * resetForm: true
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc submit form and reset it if successful
- *
- * @example
- * $('#myForm).submit(function() {
- * $(this).ajaxSubmit();
- * return false;
- * });
- * @desc Bind form's submit event to use ajaxSubmit
- *
- *
- * @name ajaxSubmit
- * @type jQuery
- * @param options object literal containing options which control the form submission process
- * @cat Plugins/Form
- * @return jQuery
- */
-$.fn.ajaxSubmit = function(options) {
- if (typeof options == 'function')
- options = { success: options };
-
- options = $.extend({
- url: this.attr('action') || window.location,
- type: this.attr('method') || 'GET'
- }, options || {});
-
- // hook for manipulating the form data before it is extracted;
- // convenient for use with rich editors like tinyMCE or FCKEditor
- var veto = {};
- $.event.trigger('form.pre.serialize', [this, options, veto]);
- if (veto.veto) return this;
-
- var a = this.formToArray(options.semantic);
-
- // give pre-submit callback an opportunity to abort the submit
- if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this;
-
- // fire vetoable 'validate' event
- $.event.trigger('form.submit.validate', [a, this, options, veto]);
- if (veto.veto) return this;
-
- var q = $.param(a);//.replace(/%20/g,'+');
-
- if (options.type.toUpperCase() == 'GET') {
- options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
- options.data = null; // data is null for 'get'
- }
- else
- options.data = q; // data is the query string for 'post'
-
- var $form = this, callbacks = [];
- if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
- if (options.clearForm) callbacks.push(function() { $form.clearForm(); });
-
- // perform a load on the target only if dataType is not provided
- if (!options.dataType && options.target) {
- var oldSuccess = options.success || function(){};
- callbacks.push(function(data) {
- if (this.evalScripts)
- $(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, arguments);
- else // jQuery v1.1.4
- $(options.target).html(data).each(oldSuccess, arguments);
- });
- }
- else if (options.success)
- callbacks.push(options.success);
-
- options.success = function(data, status) {
- for (var i=0, max=callbacks.length; i < max; i++)
- callbacks[i](data, status, $form);
- };
-
- // are there files to upload?
- var files = $('input:file', this).fieldValue();
- var found = false;
- for (var j=0; j < files.length; j++)
- if (files[j])
- found = true;
-
- if (options.iframe || found) // options.iframe allows user to force iframe mode
- fileUpload();
- else
- $.ajax(options);
-
- // fire 'notify' event
- $.event.trigger('form.submit.notify', [this, options]);
- return this;
-
-
- // private function for handling file uploads (hat tip to YAHOO!)
- function fileUpload() {
- var form = $form[0];
- var opts = $.extend({}, $.ajaxSettings, options);
-
- var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++;
- var $io = $('<iframe id="' + id + '" name="' + id + '" />');
- var io = $io[0];
- var op8 = $.browser.opera && window.opera.version() < 9;
- if ($.browser.msie || op8) io.src = 'javascript:false;document.write("");';
- $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
-
- var xhr = { // mock object
- responseText: null,
- responseXML: null,
- status: 0,
- statusText: 'n/a',
- getAllResponseHeaders: function() {},
- getResponseHeader: function() {},
- setRequestHeader: function() {}
- };
-
- var g = opts.global;
- // trigger ajax global events so that activity/block indicators work like normal
- if (g && ! $.active++) $.event.trigger("ajaxStart");
- if (g) $.event.trigger("ajaxSend", [xhr, opts]);
-
- var cbInvoked = 0;
- var timedOut = 0;
-
- // take a breath so that pending repaints get some cpu time before the upload starts
- setTimeout(function() {
- $io.appendTo('body');
- // jQuery's event binding doesn't work for iframe events in IE
- io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
-
- // make sure form attrs are set
- var encAttr = form.encoding ? 'encoding' : 'enctype';
- var t = $form.attr('target');
- $form.attr({
- target: id,
- method: 'POST',
- action: opts.url
- });
- form[encAttr] = 'multipart/form-data';
-
- // support timout
- if (opts.timeout)
- setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
-
- form.submit();
- $form.attr('target', t); // reset target
- }, 10);
-
- function cb() {
- if (cbInvoked++) return;
-
- io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
-
- var ok = true;
- try {
- if (timedOut) throw 'timeout';
- // extract the server response from the iframe
- var data, doc;
- doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
- xhr.responseText = doc.body ? doc.body.innerHTML : null;
- xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
-
- if (opts.dataType == 'json' || opts.dataType == 'script') {
- var ta = doc.getElementsByTagName('textarea')[0];
- data = ta ? ta.value : xhr.responseText;
- if (opts.dataType == 'json')
- eval("data = " + data);
- else
- $.globalEval(data);
- }
- else if (opts.dataType == 'xml') {
- data = xhr.responseXML;
- if (!data && xhr.responseText != null)
- data = toXml(xhr.responseText);
- }
- else {
- data = xhr.responseText;
- }
- }
- catch(e){
- ok = false;
- $.handleError(opts, xhr, 'error', e);
- }
-
- // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
- if (ok) {
- opts.success(data, 'success');
- if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
- }
- if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
- if (g && ! --$.active) $.event.trigger("ajaxStop");
- if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
-
- // clean up
- setTimeout(function() {
- $io.remove();
- xhr.responseXML = null;
- }, 100);
- };
-
- function toXml(s, doc) {
- if (window.ActiveXObject) {
- doc = new ActiveXObject('Microsoft.XMLDOM');
- doc.async = 'false';
- doc.loadXML(s);
- }
- else
- doc = (new DOMParser()).parseFromString(s, 'text/xml');
- return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
- };
- };
-};
-$.fn.ajaxSubmit.counter = 0; // used to create unique iframe ids
-
-/**
- * ajaxForm() provides a mechanism for fully automating form submission.
- *
- * The advantages of using this method instead of ajaxSubmit() are:
- *
- * 1: This method will include coordinates for <input type="image" /> elements (if the element
- * is used to submit the form).
- * 2. This method will include the submit element's name/value data (for the element that was
- * used to submit the form).
- * 3. This method binds the submit() method to the form for you.
- *
- * Note that for accurate x/y coordinates of image submit elements in all browsers
- * you need to also use the "dimensions" plugin (this method will auto-detect its presence).
- *
- * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
- * passes the options argument along after properly binding events for submit elements and
- * the form itself. See ajaxSubmit for a full description of the options argument.
- *
- *
- * @example
- * var options = {
- * target: '#myTargetDiv'
- * };
- * $('#myForm').ajaxSForm(options);
- * @desc Bind form's submit event so that 'myTargetDiv' is updated with the server response
- * when the form is submitted.
- *
- *
- * @example
- * var options = {
- * success: function(responseText) {
- * alert(responseText);
- * }
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc Bind form's submit event so that server response is alerted after the form is submitted.
- *
- *
- * @example
- * var options = {
- * beforeSubmit: function(formArray, jqForm) {
- * if (formArray.length == 0) {
- * alert('Please enter data.');
- * return false;
- * }
- * }
- * };
- * $('#myForm').ajaxSubmit(options);
- * @desc Bind form's submit event so that pre-submit callback is invoked before the form
- * is submitted.
- *
- *
- * @name ajaxForm
- * @param options object literal containing options which control the form submission process
- * @return jQuery
- * @cat Plugins/Form
- * @type jQuery
- */
-$.fn.ajaxForm = function(options) {
- return this.ajaxFormUnbind().submit(submitHandler).each(function() {
- // store options in hash
- this.formPluginId = $.fn.ajaxForm.counter++;
- $.fn.ajaxForm.optionHash[this.formPluginId] = options;
- $(":submit,input:image", this).click(clickHandler);
- });
-};
-
-$.fn.ajaxForm.counter = 1;
-$.fn.ajaxForm.optionHash = {};
-
-function clickHandler(e) {
- var $form = this.form;
- $form.clk = this;
- if (this.type == 'image') {
- if (e.offsetX != undefined) {
- $form.clk_x = e.offsetX;
- $form.clk_y = e.offsetY;
- } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
- var offset = $(this).offset();
- $form.clk_x = e.pageX - offset.left;
- $form.clk_y = e.pageY - offset.top;
- } else {
- $form.clk_x = e.pageX - this.offsetLeft;
- $form.clk_y = e.pageY - this.offsetTop;
- }
- }
- // clear form vars
- setTimeout(function() { $form.clk = $form.clk_x = $form.clk_y = null; }, 10);
-};
-
-function submitHandler() {
- // retrieve options from hash
- var id = this.formPluginId;
- var options = $.fn.ajaxForm.optionHash[id];
- $(this).ajaxSubmit(options);
- return false;
-};
-
-/**
- * ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
- *
- * @name ajaxFormUnbind
- * @return jQuery
- * @cat Plugins/Form
- * @type jQuery
- */
-$.fn.ajaxFormUnbind = function() {
- this.unbind('submit', submitHandler);
- return this.each(function() {
- $(":submit,input:image", this).unbind('click', clickHandler);
- });
-
-};
-
-/**
- * formToArray() gathers form element data into an array of objects that can
- * be passed to any of the following ajax functions: $.get, $.post, or load.
- * Each object in the array has both a 'name' and 'value' property. An example of
- * an array for a simple login form might be:
- *
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
- *
- * It is this array that is passed to pre-submit callback functions provided to the
- * ajaxSubmit() and ajaxForm() methods.
- *
- * The semantic argument can be used to force form serialization in semantic order.
- * This is normally true anyway, unless the form contains input elements of type='image'.
- * If your form must be submitted with name/value pairs in semantic order and your form
- * contains an input of type='image" then pass true for this arg, otherwise pass false
- * (or nothing) to avoid the overhead for this logic.
- *
- * @example var data = $("#myForm").formToArray();
- * $.post( "myscript.cgi", data );
- * @desc Collect all the data from a form and submit it to the server.
- *
- * @name formToArray
- * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
- * @type Array<Object>
- * @cat Plugins/Form
- */
-$.fn.formToArray = function(semantic) {
- var a = [];
- if (this.length == 0) return a;
-
- var form = this[0];
- var els = semantic ? form.getElementsByTagName('*') : form.elements;
- if (!els) return a;
- for(var i=0, max=els.length; i < max; i++) {
- var el = els[i];
- var n = el.name;
- if (!n) continue;
-
- if (semantic && form.clk && el.type == "image") {
- // handle image inputs on the fly when semantic == true
- if(!el.disabled && form.clk == el)
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- continue;
- }
-
- var v = $.fieldValue(el, true);
- if (v && v.constructor == Array) {
- for(var j=0, jmax=v.length; j < jmax; j++)
- a.push({name: n, value: v[j]});
- }
- else if (v !== null && typeof v != 'undefined')
- a.push({name: n, value: v});
- }
-
- if (!semantic && form.clk) {
- // input type=='image' are not found in elements array! handle them here
- var inputs = form.getElementsByTagName("input");
- for(var i=0, max=inputs.length; i < max; i++) {
- var input = inputs[i];
- var n = input.name;
- if(n && !input.disabled && input.type == "image" && form.clk == input)
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- }
- }
- return a;
-};
-
-