Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Sketchometry.activity/js/ext_jquery.js
blob: c9c54687e531213ffdabcc6e7e28b7ec521c2cf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
    Copyright 2011 / 2012

       	Alfred Wassermann
        Michael Gerhaeuser,
        Carsten Miller,
        Matthias Ehmann,
        Heiko Vogel,

    This file is part of the JSXGraph GUI project.
    This code isn't licensed yet.
*/

(function($) {

	/* Enable the text selection functionality */
	$.fn.enableSelection = function() {
		return this.each(function() {
			$(this).removeAttr('unselectable')
				.css({
					'-moz-user-select':'text',
					'-webkit-user-select':'text',
					'-khtml-user-select':'text',
					'-o-user-select':'text',
					'user-select':'text'
				});

		});
	};

	/* Disable the text selection functionality */
	$.fn.disableSelection = function() {
		return this.each(function() {
			$(this).attr('unselectable', 'on')
				.css({
					'-moz-user-select':'none',
					'-webkit-user-select':'none',
					'-khtml-user-select':'none',
					'-o-user-select':'none',
					'user-select':'none'
				});

		});
	};

	/* Compute the height of an elements margins, borders and paddings */
	$.fn.mbpHeight = function() {
		var height = parseInt(this.css('padding-top'));
		height += parseInt(this.css('padding-bottom'));
		height += parseInt(this.css('margin-top'));
		height += parseInt(this.css('margin-bottom'));
		height += parseInt(this.css('border-top-width'));
		height += parseInt(this.css('border-bottom-width'));
		return height;
	};

	/* Compute the width of an elements margins, borders and paddings */
	$.fn.mbpWidth = function() {
		var width = parseInt(this.css('padding-left'));
		width += parseInt(this.css('padding-right'));
		width += parseInt(this.css('margin-left'));
		width += parseInt(this.css('margin-right'));
		width += parseInt(this.css('border-left-width'));
		width += parseInt(this.css('border-right-width'));
		return width;
	};

	/* Compute the outer height of an element including its margins, paddings and borders */
	$.fn.outerHeight = function() {
		return parseInt(this.css('height')) + this.mbpHeight();
	};

	/* Compute the outer width of an element including its margins, paddings and borders */
	$.fn.outerWidth = function() {
		return parseInt(this.css('width')) + this.mbpWidth();
	};

    /*function scrollbarWidth() {
     var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
     // Append our div, do our calculation and then remove it
     $('body').append(div);
     var w1 = $('div', div).innerWidth();
     div.css('overflow-y', 'scroll');
     var w2 = $('div', div).innerWidth();
     $(div).remove();
     return (w1 - w2);
     }
     */

})(jQuery);