From 1357ccf882ea8c1fd30345299b1a01641aa22999 Mon Sep 17 00:00:00 2001 From: jlukic Date: Tue, 21 Jan 2014 16:44:09 -0500 Subject: [PATCH] Fixes regex matching on css variables --- server/documents/elements/button.html.eco | 2 +- server/documents/modules/dropdown.html.eco | 8 ++++ server/files/javascript/semantic.js | 44 +++++++++++----------- server/partials/header.html.eco | 10 ++--- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/server/documents/elements/button.html.eco b/server/documents/elements/button.html.eco index 44a9faae2..8f18a39ea 100755 --- a/server/documents/elements/button.html.eco +++ b/server/documents/elements/button.html.eco @@ -8,7 +8,7 @@ title : 'Button' description : 'Buttons indicate a possible user action.' type : 'UI Element' -themes : ['default', 'basic', 'github'] +themes : ['default', 'basic', 'chubby', 'github'] --- diff --git a/server/documents/modules/dropdown.html.eco b/server/documents/modules/dropdown.html.eco index a4f3a872a..1648f5aaf 100755 --- a/server/documents/modules/dropdown.html.eco +++ b/server/documents/modules/dropdown.html.eco @@ -607,6 +607,14 @@ type : 'UI Module'
activate
Most likely action will be determined by type of dropdown, for example a selection dropdown will automatically use updateForm
+
+
combo
+
changes text of previous element matching text selector
+
+
+
select
+
activates menu item but does not change text
+
nothing
no action occurs
diff --git a/server/files/javascript/semantic.js b/server/files/javascript/semantic.js index 54cb60833..728c04ac1 100755 --- a/server/files/javascript/semantic.js +++ b/server/files/javascript/semantic.js @@ -105,45 +105,46 @@ semantic.ready = function() { parseFile: function(content) { var variables = {}, - lines = content.match(/(@.*;)/g), + lines = content.match(/^(@[\s|\S]+?;)/gm), name, value ; + console.log(lines); $.each(lines, function(index, line) { // clear whitespace line = $.trim(line); // match variables only if(line[0] == '@') { name = line.match(/^@(.+):/); - value = line.match(/:(\W)(.*);/); - if( ($.isArray(name) && name.length >= 2) && ($.isArray(value) && value.length >= 3) ) { + value = line.match(/:\s*([\s|\S]+?;)/); + if( ($.isArray(name) && name.length >= 2) && ($.isArray(value) && value.length >= 2) ) { name = name[1]; - value = value[2]; + value = value[1]; variables[name] = value; } } }); - console.log(variables); return variables; }, - parseLine: function() { - // clear - }, - changeTheme: function(theme) { - $.api({ - url : '/build/less/themes/{$theme}/{$type}s/{$element}.variables', - dataType : 'text', - urlData : { - theme : theme, - type : $themeDropdown.data('type'), - element : $themeDropdown.data('element') - }, - success: function(content) { - less.modifyVars( handler.less.parseFile(content) ); - } - }) + if(theme === 'customize') { + // placeholder + } + else { + $.api({ + url : '/build/less/themes/{$theme}/{$type}s/{$element}.variables', + dataType : 'text', + urlData : { + theme : theme, + type : $themeDropdown.data('type'), + element : $themeDropdown.data('element') + }, + success: function(content) { + less.modifyVars( handler.less.parseFile(content) ); + } + }); + } } }, @@ -736,6 +737,7 @@ semantic.ready = function() { $themeDropdown .dropdown({ + action: 'select', onChange: handler.less.changeTheme }) ; diff --git a/server/partials/header.html.eco b/server/partials/header.html.eco index b17eca7a1..f83d396fe 100755 --- a/server/partials/header.html.eco +++ b/server/partials/header.html.eco @@ -24,19 +24,15 @@ <% end %> <% if @document.themes?: %> -