diff --git a/node/src/documents/modules/modal.html.eco b/node/src/documents/modules/modal.html.eco index 97949918c..5fa4cadc1 100755 --- a/node/src/documents/modules/modal.html.eco +++ b/node/src/documents/modules/modal.html.eco @@ -111,7 +111,7 @@ type : 'UI Module'

Types

-
+

Standard

A standard modal

@@ -121,7 +121,7 @@ type : 'UI Module'
-
+

Basic

A modal can reduce its complexity

diff --git a/node/src/files/javascript/semantic.js b/node/src/files/javascript/semantic.js index 517f6b0fc..7401cda28 100755 --- a/node/src/files/javascript/semantic.js +++ b/node/src/files/javascript/semantic.js @@ -234,27 +234,16 @@ semantic.ready = function() { ; }, - createCode: function(type) { + generateCode: function() { var $example = $(this).closest('.example'), - $header = $example.children('.ui.header:first-of-type').eq(0).add('p:first-of-type'), - $demo = $example.children().not($header).not('i.code:first-child, .code, .language.label, .annotation, br, .ignore, .ignored'), $annotation = $example.find('.annotation'), $code = $annotation.find('.code'), + $header = $example.children('.ui.header:first-of-type').eq(0).add('p:first-of-type'), + $demo = $example.children().not($header).not('i.code:first-child, .code, .instructive, .language.label, .annotation, br, .ignore, .ignored'), whiteSpace = new RegExp('\\n\\s{4}', 'g'), - code = '' + code = '' ; - if($annotation.size() === 0) { - $annotation = $('
') - .addClass('annotation') - .appendTo($example) - ; - } - if( $code.hasClass('existing') ) { - $annotation.show(); - $code.removeClass('existing'); - $.proxy(handler.initializeCode, $code)(); - } if( $code.size() === 0) { $demo .each(function(){ @@ -264,15 +253,45 @@ semantic.ready = function() { } }) ; - //code = $.trim(code.replace(whiteSpace, '\n')); + } + $example.data('code', code); + return code; + }, + createCode: function(type) { + var + $example = $(this).closest('.example'), + $header = $example.children('.ui.header:first-of-type').eq(0).add('p:first-of-type'), + $annotation = $example.find('.annotation'), + $code = $annotation.find('.code'), + $demo = $example.children().not($header).not('i.code:first-child, .code, .instructive, .language.label, .annotation, br, .ignore, .ignored'), + code = $example.data('code') + ; + if( $code.hasClass('existing') ) { + $annotation.show(); + $code.removeClass('existing'); + $.proxy(handler.initializeCode, $code)(); + } + + $.proxy(handler.generateCode, this)(); + + if($annotation.size() === 0) { + $annotation = $('
') + .addClass('annotation') + .appendTo($example) + ; + } + + if( $example.find('.ace_editor').size() === 0) { $code = $('
') .data('type', 'html') .addClass('code') .html(code) + .hide() .appendTo($annotation) ; $.proxy(handler.initializeCode, $code)(); } + if( ($demo.first().is(':visible') || type == 'developer') && type != 'designer' ) { $demo.hide(); $header.show(); @@ -300,9 +319,29 @@ semantic.ready = function() { ; }, + resizeCode: function() { + $('.ace_editor') + .each(function() { + var + $code = $(this), + padding = 4, + editor, + editorSession, + codeHeight + ; + $code.css('height', 'auto'); + editor = ace.edit($code[0]); + editorSession = editor.getSession(); + codeHeight = editor.session.getScreenLength() * (editor.renderer.lineHeight) + editor.renderer.scrollBar.getWidth() + padding; + $code.css('height', codeHeight); + editor.resize(); + }) + ; + }, + initializeCode: function() { var - $code = $(this), + $code = $(this).show(), code = $code.html(), existingCode = $code.hasClass('existing'), contentType = $code.data('type') || 'javascript', @@ -354,7 +393,7 @@ semantic.ready = function() { editorSession.setTabSize(2); editorSession.setUseSoftTabs(true); - codeHeight = editor.session.getScreenLength() * (editor.renderer.lineHeight) + editor.renderer.scrollBar.getWidth() + padding; + codeHeight = editorSession.getScreenLength() * (editor.renderer.lineHeight) + editor.renderer.scrollBar.getWidth() + padding; $(this) .height(codeHeight + 'px') .wrap('
') @@ -541,6 +580,13 @@ semantic.ready = function() { } }; + $(window) + .on('resize', function() { + clearTimeout(handler.timer); + handler.timer = setTimeout(handler.resizeCode, 100); + }) + ; + $downloadDropdown .dropdown({ on : 'click', @@ -565,7 +611,9 @@ semantic.ready = function() { } handler.createIcon(); + $example + .one('mousemove', handler.generateCode) .find('i.code') .on('click', handler.createCode) ;