From f0cce6c9cd2af1372d3e268ba8531d56ec4f2258 Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Wed, 15 May 2013 19:36:23 -0400 Subject: [PATCH] fixing performance logging Former-commit-id: d176221483eea999b30dcd92343e65e7f03d21b5 Former-commit-id: 94c675e4c43ef0bf0dbd1cdb951a81e68bb1a6f5 --- node/src/documents/module.html | 40 +++--- node/src/documents/modules/checkbox.html | 130 ++---------------- .../semantic/src/collections/message.css | 10 +- .../semantic/src/modules/checkbox.js | 71 ++++------ src/modules/checkbox.js | 71 ++++------ 5 files changed, 91 insertions(+), 231 deletions(-) diff --git a/node/src/documents/module.html b/node/src/documents/module.html index da69dcc49..2a4b8cfd1 100755 --- a/node/src/documents/module.html +++ b/node/src/documents/module.html @@ -1,6 +1,6 @@ --- layout : 'default' -css : 'index' +css : 'module' title : 'UI Modules' type : 'Semantic' @@ -74,29 +74,37 @@ type : 'Semantic'

Changing Settings

  1. A settings object can be passed in when initializing the plugin -
    $('.foo') - .module({ - moduleName: 'Godzilla', - verbose: true - }) -;
    +
    +
    + $('.foo') + .module({ + moduleName: 'Godzilla', + verbose: true + }) + ; +
  2. Default settings for the module can be overridden by modifying $.fn.module.settings.
    $.fn.module.settings.moduleName = 'Godzilla';
  3. Settings can be changed after a module is initialized by calling the 'settings' method on the module with either a settings object or a name, value pair. -
    $('.foo') - // lets initialize that! - .module() - // oh wait forgot something - .module('setting', 'moduleName', 'Godzilla') -;
    +
    +
    + $('.foo') + // lets initialize that! + .module() + // oh wait forgot something + .module('setting', 'moduleName', 'Godzilla') + ; +

Reading Settings

-

Settings can also be read programmatically:

$('.foo').module('setting', 'moduleName'); -// outputs godzilla
- +

Settings can also be read programmatically: +

+ $('.foo').module('setting', 'moduleName'); + // outputs godzilla +
diff --git a/node/src/documents/modules/checkbox.html b/node/src/documents/modules/checkbox.html index a72e373aa..33079da39 100755 --- a/node/src/documents/modules/checkbox.html +++ b/node/src/documents/modules/checkbox.html @@ -35,7 +35,7 @@ type : 'UI Module'
-

Check Box

+

Static Check Box

A checkbox can function without javascript

@@ -47,24 +47,18 @@ type : 'UI Module'

Form Checkbox

A checkbox can be found inside a form

-
-
- - -
-
- - -
+
+ +
- +
-
Submit
+
Submit
@@ -177,110 +171,6 @@ type : 'UI Module'
- - - - -

You can disable a checkbox programmatically using the disable method

-
- $('.ui.checkbox') - .checkbox('disable') - ; -

Getting Started

Initializing a check box

@@ -360,9 +250,11 @@ type : 'UI Module' errors -
errors : { - method : 'The method you called is not defined.' - }
+
+ errors : { + method : 'The method you called is not defined.' + } +
diff --git a/node/src/files/components/semantic/src/collections/message.css b/node/src/files/components/semantic/src/collections/message.css index 10b52ccc3..2cde5696a 100755 --- a/node/src/files/components/semantic/src/collections/message.css +++ b/node/src/files/components/semantic/src/collections/message.css @@ -30,12 +30,7 @@ -moz-border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px; } -.ui.message :first-child { - margin-top: 0em; -} -.ui.message :last-child { - margin-bottom: 0em; -} + /*-------------- Content @@ -52,6 +47,9 @@ opacity: 0.85; margin: 1em 0em; } +.ui.message p:first-child { + margin-top: 0em; +} /* block with child list */ .ui.message ul.list { diff --git a/node/src/files/components/semantic/src/modules/checkbox.js b/node/src/files/components/semantic/src/modules/checkbox.js index 95cf84f9d..23fedc290 100644 --- a/node/src/files/components/semantic/src/modules/checkbox.js +++ b/node/src/files/components/semantic/src/modules/checkbox.js @@ -73,15 +73,6 @@ $.fn.checkbox = function(parameters) { ; }, - toggle: function() { - if( $input.prop('checked') === undefined || !$input.prop('checked') ) { - module.enable(); - } - else { - module.disable(); - } - }, - enable: function() { module.debug('Enabling checkbox'); $module @@ -106,27 +97,15 @@ $.fn.checkbox = function(parameters) { $.proxy(settings.onDisable, $input.get())(); }, - all: { - enable: function() { - module.debug('Enabling all checkbox'); - $allModules - .checkbox('enable') - ; - }, - disable: function() { - module.debug('Disabling all checkbox'); - $allModules - .checkbox('toggle') - ; - }, - toggle: function() { - module.debug('Toggling all checkbox'); - $allModules - .checkbox('toggle') - ; + toggle: function() { + if( $input.prop('checked') === undefined || !$input.prop('checked') ) { + module.enable(); + } + else { + module.disable(); } }, - + setting: function(name, value) { if(value !== undefined) { if( $.isPlainObject(name) ) { @@ -183,6 +162,7 @@ $.fn.checkbox = function(parameters) { executionTime = currentTime - previousTime; time = currentTime; performance.push({ + 'Element' : element, 'Name' : message, 'Execution Time' : executionTime }); @@ -192,12 +172,15 @@ $.fn.checkbox = function(parameters) { }, display: function() { var - title = settings.moduleName + ' Performance (' + selector + ')', + title = settings.moduleName, caption = settings.moduleName + ': ' + selector + '(' + $allModules.size() + ' elements)', totalExecutionTime = 0 ; + if(selector) { + title += 'Performance (' + selector + ')'; + } if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { - console.groupCollapsed(title ); + console.groupCollapsed(title); if(console.table) { $.each(performance, function(index, data) { totalExecutionTime += data['Execution Time']; @@ -209,7 +192,7 @@ $.fn.checkbox = function(parameters) { totalExecutionTime += data['Execution Time']; }); } - console.log('Total Execution Time:', totalExecutionTime); + console.log('Total Execution Time:', totalExecutionTime +'ms'); console.groupEnd(); performance = []; time = false; @@ -235,7 +218,7 @@ $.fn.checkbox = function(parameters) { found = instance[value]; return true; } - module.error(error.method); + module.error(errors.method); return false; }); } @@ -247,7 +230,6 @@ $.fn.checkbox = function(parameters) { } }; - // check for invoking internal method if(methodInvoked) { if(instance === undefined) { module.initialize(); @@ -262,7 +244,6 @@ $.fn.checkbox = function(parameters) { } }) ; - // chain or return queried method return (invokedResponse) ? invokedResponse : this @@ -271,20 +252,20 @@ $.fn.checkbox = function(parameters) { $.fn.checkbox.settings = { - // module info - moduleName : 'Checkbox Module', - verbose : false, - debug : true, - namespace : 'checkbox', + moduleName : 'Checkbox Module', + namespace : 'checkbox', - // delegated event context - context : false, + verbose : true, + debug : true, + performance : true, - onChange : function(){}, - onEnable : function(){}, - onDisable : function(){}, + // delegated event context + context : false, + + onChange : function(){}, + onEnable : function(){}, + onDisable : function(){}, - // errors errors : { method : 'The method you called is not defined.' }, diff --git a/src/modules/checkbox.js b/src/modules/checkbox.js index 95cf84f9d..23fedc290 100755 --- a/src/modules/checkbox.js +++ b/src/modules/checkbox.js @@ -73,15 +73,6 @@ $.fn.checkbox = function(parameters) { ; }, - toggle: function() { - if( $input.prop('checked') === undefined || !$input.prop('checked') ) { - module.enable(); - } - else { - module.disable(); - } - }, - enable: function() { module.debug('Enabling checkbox'); $module @@ -106,27 +97,15 @@ $.fn.checkbox = function(parameters) { $.proxy(settings.onDisable, $input.get())(); }, - all: { - enable: function() { - module.debug('Enabling all checkbox'); - $allModules - .checkbox('enable') - ; - }, - disable: function() { - module.debug('Disabling all checkbox'); - $allModules - .checkbox('toggle') - ; - }, - toggle: function() { - module.debug('Toggling all checkbox'); - $allModules - .checkbox('toggle') - ; + toggle: function() { + if( $input.prop('checked') === undefined || !$input.prop('checked') ) { + module.enable(); + } + else { + module.disable(); } }, - + setting: function(name, value) { if(value !== undefined) { if( $.isPlainObject(name) ) { @@ -183,6 +162,7 @@ $.fn.checkbox = function(parameters) { executionTime = currentTime - previousTime; time = currentTime; performance.push({ + 'Element' : element, 'Name' : message, 'Execution Time' : executionTime }); @@ -192,12 +172,15 @@ $.fn.checkbox = function(parameters) { }, display: function() { var - title = settings.moduleName + ' Performance (' + selector + ')', + title = settings.moduleName, caption = settings.moduleName + ': ' + selector + '(' + $allModules.size() + ' elements)', totalExecutionTime = 0 ; + if(selector) { + title += 'Performance (' + selector + ')'; + } if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { - console.groupCollapsed(title ); + console.groupCollapsed(title); if(console.table) { $.each(performance, function(index, data) { totalExecutionTime += data['Execution Time']; @@ -209,7 +192,7 @@ $.fn.checkbox = function(parameters) { totalExecutionTime += data['Execution Time']; }); } - console.log('Total Execution Time:', totalExecutionTime); + console.log('Total Execution Time:', totalExecutionTime +'ms'); console.groupEnd(); performance = []; time = false; @@ -235,7 +218,7 @@ $.fn.checkbox = function(parameters) { found = instance[value]; return true; } - module.error(error.method); + module.error(errors.method); return false; }); } @@ -247,7 +230,6 @@ $.fn.checkbox = function(parameters) { } }; - // check for invoking internal method if(methodInvoked) { if(instance === undefined) { module.initialize(); @@ -262,7 +244,6 @@ $.fn.checkbox = function(parameters) { } }) ; - // chain or return queried method return (invokedResponse) ? invokedResponse : this @@ -271,20 +252,20 @@ $.fn.checkbox = function(parameters) { $.fn.checkbox.settings = { - // module info - moduleName : 'Checkbox Module', - verbose : false, - debug : true, - namespace : 'checkbox', + moduleName : 'Checkbox Module', + namespace : 'checkbox', - // delegated event context - context : false, + verbose : true, + debug : true, + performance : true, - onChange : function(){}, - onEnable : function(){}, - onDisable : function(){}, + // delegated event context + context : false, + + onChange : function(){}, + onEnable : function(){}, + onDisable : function(){}, - // errors errors : { method : 'The method you called is not defined.' },