comparison core.js @ 1524:9c1550a1de6e

Bug #1300: Boxes are automatically scaled on load. Will add to 'resize' commands in the future.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Mon, 14 Sep 2015 16:25:13 +0100
parents ed1d17b94752
children 1dc56cb86152
comparison
equal deleted inserted replaced
1523:ed1d17b94752 1524:9c1550a1de6e
1752 var audioHolderObject = audioObject.specification.parent; 1752 var audioHolderObject = audioObject.specification.parent;
1753 // Create document objects to hold the comment boxes 1753 // Create document objects to hold the comment boxes
1754 this.trackComment = document.createElement('div'); 1754 this.trackComment = document.createElement('div');
1755 this.trackComment.className = 'comment-div'; 1755 this.trackComment.className = 'comment-div';
1756 this.trackComment.id = 'comment-div-'+audioObject.id; 1756 this.trackComment.id = 'comment-div-'+audioObject.id;
1757 var boxwidth = (window.innerWidth-100)/2;
1758 if (boxwidth >= 624)
1759 {
1760 boxwidth = 624;
1761 }
1762 else if (boxwidth < 400)
1763 {
1764 boxwidth = 400;
1765 }
1766 this.trackComment.style.width = boxwidth+"px";
1757 // Create a string next to each comment asking for a comment 1767 // Create a string next to each comment asking for a comment
1758 this.trackString = document.createElement('span'); 1768 this.trackString = document.createElement('span');
1759 this.trackString.innerHTML = audioHolderObject.commentBoxPrefix+' '+audioObject.id; 1769 this.trackString.innerHTML = audioHolderObject.commentBoxPrefix+' '+audioObject.id;
1760 // Create the HTML5 comment box 'textarea' 1770 // Create the HTML5 comment box 'textarea'
1761 this.trackCommentBox = document.createElement('textarea'); 1771 this.trackCommentBox = document.createElement('textarea');
1762 this.trackCommentBox.rows = '4'; 1772 this.trackCommentBox.rows = '4';
1763 this.trackCommentBox.cols = '100'; 1773 this.trackCommentBox.cols = '100';
1764 this.trackCommentBox.name = 'trackComment'+audioObject.id; 1774 this.trackCommentBox.name = 'trackComment'+audioObject.id;
1765 this.trackCommentBox.className = 'trackComment'; 1775 this.trackCommentBox.className = 'trackComment';
1776 this.trackCommentBox.style.width = boxwidth-6+"px";
1766 var br = document.createElement('br'); 1777 var br = document.createElement('br');
1767 // Add to the holder. 1778 // Add to the holder.
1768 this.trackComment.appendChild(this.trackString); 1779 this.trackComment.appendChild(this.trackString);
1769 this.trackComment.appendChild(br); 1780 this.trackComment.appendChild(br);
1770 this.trackComment.appendChild(this.trackCommentBox); 1781 this.trackComment.appendChild(this.trackCommentBox);
1789 this.commentBox = function(commentQuestion) { 1800 this.commentBox = function(commentQuestion) {
1790 this.specification = commentQuestion; 1801 this.specification = commentQuestion;
1791 // Create document objects to hold the comment boxes 1802 // Create document objects to hold the comment boxes
1792 this.holder = document.createElement('div'); 1803 this.holder = document.createElement('div');
1793 this.holder.className = 'comment-div'; 1804 this.holder.className = 'comment-div';
1805 var boxwidth = (window.innerWidth-100)/2;
1806 if (boxwidth >= 624)
1807 {
1808 boxwidth = 624;
1809 }
1810 else if (boxwidth < 400)
1811 {
1812 boxwidth = 400;
1813 }
1814 this.holder.style.width = boxwidth+"px";
1794 // Create a string next to each comment asking for a comment 1815 // Create a string next to each comment asking for a comment
1795 this.string = document.createElement('span'); 1816 this.string = document.createElement('span');
1796 this.string.innerHTML = commentQuestion.question; 1817 this.string.innerHTML = commentQuestion.question;
1797 // Create the HTML5 comment box 'textarea' 1818 // Create the HTML5 comment box 'textarea'
1798 this.textArea = document.createElement('textarea'); 1819 this.textArea = document.createElement('textarea');
1799 this.textArea.rows = '4'; 1820 this.textArea.rows = '4';
1800 this.textArea.cols = '100'; 1821 this.textArea.cols = '100';
1801 this.textArea.className = 'trackComment'; 1822 this.textArea.className = 'trackComment';
1823 this.textArea.style.width = boxwidth-6+"px";
1802 var br = document.createElement('br'); 1824 var br = document.createElement('br');
1803 // Add to the holder. 1825 // Add to the holder.
1804 this.holder.appendChild(this.string); 1826 this.holder.appendChild(this.string);
1805 this.holder.appendChild(br); 1827 this.holder.appendChild(br);
1806 this.holder.appendChild(this.textArea); 1828 this.holder.appendChild(this.textArea);
1819 this.radioBox = function(commentQuestion) { 1841 this.radioBox = function(commentQuestion) {
1820 this.specification = commentQuestion; 1842 this.specification = commentQuestion;
1821 // Create document objects to hold the comment boxes 1843 // Create document objects to hold the comment boxes
1822 this.holder = document.createElement('div'); 1844 this.holder = document.createElement('div');
1823 this.holder.className = 'comment-div'; 1845 this.holder.className = 'comment-div';
1846 var boxwidth = (window.innerWidth-100)/2;
1847 if (boxwidth >= 624)
1848 {
1849 boxwidth = 624;
1850 }
1851 else if (boxwidth < 400)
1852 {
1853 boxwidth = 400;
1854 }
1855 this.holder.style.width = boxwidth+"px";
1824 // Create a string next to each comment asking for a comment 1856 // Create a string next to each comment asking for a comment
1825 this.string = document.createElement('span'); 1857 this.string = document.createElement('span');
1826 this.string.innerHTML = commentQuestion.statement; 1858 this.string.innerHTML = commentQuestion.statement;
1827 var br = document.createElement('br'); 1859 var br = document.createElement('br');
1828 // Add to the holder. 1860 // Add to the holder.
1836 this.span.style.marginLeft = '12px'; 1868 this.span.style.marginLeft = '12px';
1837 this.span.align = 'center'; 1869 this.span.align = 'center';
1838 this.span.style.marginTop = '15px'; 1870 this.span.style.marginTop = '15px';
1839 1871
1840 var optCount = commentQuestion.options.length; 1872 var optCount = commentQuestion.options.length;
1841 var spanMargin = Math.floor(((600-(optCount*100))/(optCount))/2)+'px'; 1873 var spanMargin = Math.floor(((boxwidth-20-(optCount*80))/(optCount))/2)+'px';
1842 console.log(spanMargin);
1843 for (var i=0; i<optCount; i++) 1874 for (var i=0; i<optCount; i++)
1844 { 1875 {
1845 var div = document.createElement('div'); 1876 var div = document.createElement('div');
1846 div.style.width = '100px'; 1877 div.style.width = '80px';
1847 div.style.float = 'left'; 1878 div.style.float = 'left';
1848 div.style.marginRight = spanMargin; 1879 div.style.marginRight = spanMargin;
1849 div.style.marginLeft = spanMargin; 1880 div.style.marginLeft = spanMargin;
1850 var input = document.createElement('input'); 1881 var input = document.createElement('input');
1851 input.type = 'radio'; 1882 input.type = 'radio';
1855 div.appendChild(input); 1886 div.appendChild(input);
1856 this.inputs.appendChild(div); 1887 this.inputs.appendChild(div);
1857 1888
1858 1889
1859 div = document.createElement('div'); 1890 div = document.createElement('div');
1860 div.style.width = '100px'; 1891 div.style.width = '80px';
1861 div.style.float = 'left'; 1892 div.style.float = 'left';
1862 div.style.marginRight = spanMargin; 1893 div.style.marginRight = spanMargin;
1863 div.style.marginLeft = spanMargin; 1894 div.style.marginLeft = spanMargin;
1864 div.align = 'center'; 1895 div.align = 'center';
1865 var span = document.createElement('span'); 1896 var span = document.createElement('span');
1903 this.checkboxBox = function(commentQuestion) { 1934 this.checkboxBox = function(commentQuestion) {
1904 this.specification = commentQuestion; 1935 this.specification = commentQuestion;
1905 // Create document objects to hold the comment boxes 1936 // Create document objects to hold the comment boxes
1906 this.holder = document.createElement('div'); 1937 this.holder = document.createElement('div');
1907 this.holder.className = 'comment-div'; 1938 this.holder.className = 'comment-div';
1939 var boxwidth = (window.innerWidth-100)/2;
1940 if (boxwidth >= 624)
1941 {
1942 boxwidth = 624;
1943 }
1944 else if (boxwidth < 400)
1945 {
1946 boxwidth = 400;
1947 }
1948 this.holder.style.width = boxwidth+"px";
1908 // Create a string next to each comment asking for a comment 1949 // Create a string next to each comment asking for a comment
1909 this.string = document.createElement('span'); 1950 this.string = document.createElement('span');
1910 this.string.innerHTML = commentQuestion.statement; 1951 this.string.innerHTML = commentQuestion.statement;
1911 var br = document.createElement('br'); 1952 var br = document.createElement('br');
1912 // Add to the holder. 1953 // Add to the holder.
1920 this.span.style.marginLeft = '12px'; 1961 this.span.style.marginLeft = '12px';
1921 this.span.align = 'center'; 1962 this.span.align = 'center';
1922 this.span.style.marginTop = '15px'; 1963 this.span.style.marginTop = '15px';
1923 1964
1924 var optCount = commentQuestion.options.length; 1965 var optCount = commentQuestion.options.length;
1925 var spanMargin = Math.floor(((600-(optCount*100))/(optCount))/2)+'px'; 1966 var spanMargin = Math.floor(((boxwidth-20-(optCount*80))/(optCount))/2)+'px';
1926 console.log(spanMargin);
1927 for (var i=0; i<optCount; i++) 1967 for (var i=0; i<optCount; i++)
1928 { 1968 {
1929 var div = document.createElement('div'); 1969 var div = document.createElement('div');
1930 div.style.width = '100px'; 1970 div.style.width = '80px';
1931 div.style.float = 'left'; 1971 div.style.float = 'left';
1932 div.style.marginRight = spanMargin; 1972 div.style.marginRight = spanMargin;
1933 div.style.marginLeft = spanMargin; 1973 div.style.marginLeft = spanMargin;
1934 var input = document.createElement('input'); 1974 var input = document.createElement('input');
1935 input.type = 'checkbox'; 1975 input.type = 'checkbox';
1939 div.appendChild(input); 1979 div.appendChild(input);
1940 this.inputs.appendChild(div); 1980 this.inputs.appendChild(div);
1941 1981
1942 1982
1943 div = document.createElement('div'); 1983 div = document.createElement('div');
1944 div.style.width = '100px'; 1984 div.style.width = '80px';
1945 div.style.float = 'left'; 1985 div.style.float = 'left';
1946 div.style.marginRight = spanMargin; 1986 div.style.marginRight = spanMargin;
1947 div.style.marginLeft = spanMargin; 1987 div.style.marginLeft = spanMargin;
1948 div.align = 'center'; 1988 div.align = 'center';
1949 var span = document.createElement('span'); 1989 var span = document.createElement('span');