Skip to content
This repository
Browse code

MINOR Remove unused AssetTableField js file

  • Loading branch information...
commit 673dd7d992503237ef7a60d889d6fedce558a523 1 parent fa999ca
Simon Welsh authored March 24, 2012

Showing 1 changed file with 0 additions and 161 deletions. Show diff stats Hide diff stats

  1. 161  admin/javascript/AssetTableField.js
161  admin/javascript/AssetTableField.js
... ...
@@ -1,161 +0,0 @@
1  
-/**
2  
- * File: AssetTableField.js
3  
- */
4  
-(function($) {
5  
-	$.entwine('ss', function($){
6  
-		
7  
-		/**
8  
-		 * Class: .AssetTableField
9  
-		 */
10  
-		$('.AssetTableField').entwine({
11  
-			// Constructor: onmatch
12  
-			onmatch: function() {
13  
-				var self = this;
14  
-				
15  
-				// search button
16  
-				this.find('input#FileFilterButton').click(function(e) {
17  
-					var btn = $(this);
18  
-					$(this).addClass('loading');
19  
-					self.refresh(function() {btn.removeClass('loading');});
20  
-					return false;
21  
-				});
22  
-				
23  
-				// clear button
24  
-				this.find('input#FileFilterClearButton').click(function(e) {
25  
-					self.find('input#FileSearch').val('');
26  
-					self.find('input#FileFilterButton').click();
27  
-					return false;
28  
-				});
29  
-				
30  
-				// search field
31  
-				this.find('input#FileSearch').keypress(function(e) {
32  
-					if(e.keyCode == $.ui.keyCode.ENTER) {
33  
-						self.find('input#FileFilterButton').click();
34  
-					}
35  
-				});
36  
-				
37  
-				this._super();
38  
-			},
39  
-			
40  
-			/**
41  
-			 * Function: refresh
42  
-			 * 
43  
-			 * Parameters:
44  
-			 * (Function) callback
45  
-			 */
46  
-			refresh: function(callback) {
47  
-				var self = this;
48  
-				this.load(
49  
-					this.attr('href'),
50  
-					this.find(':input').serialize(),
51  
-					function(response, status, xmlhttp) {
52  
-						Behaviour.apply(self[0], true);
53  
-						if(callback) callback.apply(arguments);
54  
-					}
55  
-				);
56  
-			}
57  
-		});
58  
-		
59  
-		/**
60  
-		 * Class: .AssetTableField :checkbox
61  
-		 * 
62  
-		 * Checkboxes used to batch delete files
63  
-		 */
64  
-		$('.AssetTableField :checkbox').entwine({
65  
-			// Function: onchange
66  
-			onchange: function() {
67  
-				var container = this.parents('.AssetTableField');
68  
-				var input = container.find('input#deletemarked');
69  
-				if(container.find(':input[name=Files\[\]]:checked').length) {
70  
-					input.removeAttr('disabled');
71  
-				} else {
72  
-					input.attr('disabled', 'disabled');
73  
-				}
74  
-			}
75  
-		})
76  
-		
77  
-		/**
78  
-		 * Class: .AssetTableField input#deletemarked
79  
-		 * 
80  
-		 * Batch delete files marked by checkboxes in the table.
81  
-		 * Refreshes the form field afterwards via ajax.
82  
-		 */
83  
-		$('.AssetTableField input#deletemarked').entwine({
84  
-			// Constructor: onmatch
85  
-			onmatch: function() {
86  
-				this.attr('disabled', 'disabled');
87  
-				this._super();
88  
-			},
89  
-			
90  
-			/**
91  
-			 * Function: onclick
92  
-			 * 
93  
-			 * Parameters:
94  
-			 * (Event) e
95  
-			 */
96  
-			onclick: function(e) {
97  
-				if(!confirm(ss.i18n._t('AssetTableField.REALLYDELETE'))) return false;
98  
-				
99  
-				var container = this.parents('.AssetTableField');
100  
-				var self = this;
101  
-				this.addClass('loading');
102  
-				$.post(
103  
-					container.attr('href') + '/deletemarked',
104  
-					this.parents('form').serialize(),
105  
-					function(data, status) {
106  
-						self.removeClass('loading');
107  
-						container.refresh();
108  
-					}
109  
-				);
110  
-				return false;
111  
-			}
112  
-		});
113  
-	});
114  
-}(jQuery));
115  
-
116  
-// TODO Implementation in Behaviour instead of entwine is necessary to overload TableListField
117  
-var AssetTableField = Class.create();
118  
-AssetTableField.applyTo('#Form_EditForm_Files');
119  
-AssetTableField.prototype = {
120  
-	initialize: function() {
121  
-		var rules = {};
122  
-		rules['#'+this.id+' table.data a.deletelink'] = {onclick: this.deleteRecord.bind(this)};
123  
-		Behaviour.register('ComplexTableField_'+this.id,rules);
124  
-	},
125  
-	
126  
-	deleteRecord: function(e) {
127  
-		var self = this, img = Event.element(e), link = Event.findElement(e,"a"), row = Event.findElement(e,"tr");
128  
-		
129  
-		var linkCount = row.getElementsByClassName('linkCount')[0];
130  
-		if(linkCount) linkCount = linkCount.innerHTML;
131  
-		
132  
-		var confirmMessage = ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE', 'Are you sure you want to delete this record?');
133  
-		if(linkCount && linkCount > 0) confirmMessage += '\nThere are ' + linkCount + ' page(s) that use this file, please review the list of pages on the Links tab of the file before continuing.';
134  
-
135  
-		// TODO ajaxErrorHandler and loading-image are dependent on cms, but formfield is in sapphire
136  
-		var confirmed = confirm(confirmMessage);
137  
-		if(confirmed)
138  
-		{
139  
-			img.setAttribute("src",'sapphire/admin/images/network-save.gif'); // TODO doesn't work
140  
-			jQuery.ajax({
141  
-				url: link.getAttribute("href"),
142  
-				method: 'post',
143  
-				data: {forceajax: 1, SecurityID: jQuery('input[name=SecurityID]').val()},
144  
-				success: function() {
145  
-					jQuery(row).fadeOut('fast', function() {
146  
-						// remove row from DOM
147  
-						this.element.parentNode.removeChild(obj.element);
148  
-						// recalculate summary if needed (assumes that TableListField.js is present)
149  
-						// TODO Proper inheritance
150  
-						if(self._summarise) self._summarise();
151  
-						// custom callback
152  
-						if(self.callback_deleteRecord) self.callback_deleteRecord(e);
153  
-					}
154  
-				}
155  
-			});
156  
-				
157  
-		}
158  
-		
159  
-		Event.stop(e);
160  
-	}
161  
-};

0 notes on commit 673dd7d

Please sign in to comment.
Something went wrong with that request. Please try again.