Subversion Repositories SmartDukaan

Rev

Rev 13758 | Rev 14408 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13758 Rev 14098
Line 1... Line 1...
1
$(function(){
1
$(function(){
2
	$('.brandedit').on('click',function(){
-
 
3
		var that = $(this);
-
 
4
		var value = 0;
-
 
5
		if($(this).prop('checked')){
-
 
6
			value = 1;
-
 
7
		}
-
 
8
		$.post($(this).data('url'),{'id':$(this).data('id'),'displayed_in_preference_page':value},function(data){
-
 
9
			if(data.success){$(that).parent().append('Done');};
-
 
10
		})
-
 
11
	})
-
 
12
});
-
 
13
2
	if($('.brandedit').length){
-
 
3
		$('.brandedit').on('click',function(){
-
 
4
			var that = $(this);
-
 
5
			var value = 0;
-
 
6
			if($(this).prop('checked')){
-
 
7
				value = 1;
-
 
8
			}
-
 
9
			$.post($(this).data('url'),{'id':$(this).data('id'),'displayed_in_preference_page':value},function(data){
-
 
10
				if(data.success){$(that).parent().append('Done');};
-
 
11
			})
-
 
12
		});
-
 
13
	}
-
 
14
    $('.edit').editable(base_url+'admin/'+controller+'/update/',{
-
 
15
    	onsubmit: function(settings, td) {
-
 
16
	      	var input = $(td).find('input');
-
 
17
	        var original = input.val();
-
 
18
	        if (isNumeric(original)) {
-
 
19
	            console.log("Validation correct");
-
 
20
	            return true;
-
 
21
	        } else {
-
 
22
	            console.log("Validation failed. Ignoring");
-
 
23
	            input.css('background-color','#c00').css('color','#fff');
-
 
24
	            return false;
-
 
25
	        }
-
 
26
	    },
-
 
27
        indicator : 'Saving...',
-
 
28
        tooltip   : 'Click to edit...',
-
 
29
        submit : 'OK',
-
 
30
      	submitdata : function(value, settings) {
-
 
31
	       return {oid: $(this).data('oid')};
-
 
32
	   }
-
 
33
    });
-
 
34
});
-
 
35
function isNumeric(value) {
-
 
36
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
-
 
37
  return true;
-
 
38
}
-
 
39
14
40