Commit bfecf9d5 authored by Maxim Kadushkin's avatar Maxim Kadushkin

moved module dependencies

parent 9e9e738d
...@@ -35,22 +35,23 @@ if (Common === undefined) ...@@ -35,22 +35,23 @@ if (Common === undefined)
Common.component = Common.component || {}; Common.component = Common.component || {};
Common.Analytics = Common.component.Analytics = new(function() { define(['jquery'], function($){
var _category; Common.Analytics = Common.component.Analytics = new(function() {
var _category;
return { return {
initialize: function(id, category) { initialize: function(id, category) {
if (typeof id === 'undefined') if (typeof id === 'undefined')
throw 'Analytics: invalid id.'; throw 'Analytics: invalid id.';
if (typeof category === 'undefined' || Object.prototype.toString.apply(category) !== '[object String]') if (typeof category === 'undefined' || Object.prototype.toString.apply(category) !== '[object String]')
throw 'Analytics: invalid category type.'; throw 'Analytics: invalid category type.';
_category = category; _category = category;
$('head').append( $('head').append(
'<script type="text/javascript">' + '<script type="text/javascript">' +
'var _gaq = _gaq || [];' + 'var _gaq = _gaq || [];' +
'_gaq.push(["_setAccount", "' + id + '"]);' + '_gaq.push(["_setAccount", "' + id + '"]);' +
'_gaq.push(["_trackPageview"]);' + '_gaq.push(["_trackPageview"]);' +
...@@ -60,27 +61,28 @@ Common.Analytics = Common.component.Analytics = new(function() { ...@@ -60,27 +61,28 @@ Common.Analytics = Common.component.Analytics = new(function() {
'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' + 'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' +
'})();' + '})();' +
'</script>' '</script>'
); );
}, },
trackEvent: function(action, label, value) { trackEvent: function(action, label, value) {
if (typeof action !== 'undefined' && Object.prototype.toString.apply(action) !== '[object String]') if (typeof action !== 'undefined' && Object.prototype.toString.apply(action) !== '[object String]')
throw 'Analytics: invalid action type.'; throw 'Analytics: invalid action type.';
if (typeof label !== 'undefined' && Object.prototype.toString.apply(label) !== '[object String]') if (typeof label !== 'undefined' && Object.prototype.toString.apply(label) !== '[object String]')
throw 'Analytics: invalid label type.'; throw 'Analytics: invalid label type.';
if (typeof value !== 'undefined' && !(Object.prototype.toString.apply(value) === '[object Number]' && isFinite(value))) if (typeof value !== 'undefined' && !(Object.prototype.toString.apply(value) === '[object Number]' && isFinite(value)))
throw 'Analytics: invalid value type.'; throw 'Analytics: invalid value type.';
if (typeof _gaq === 'undefined') if (typeof _gaq === 'undefined')
return; return;
if (_category === 'undefined') if (_category === 'undefined')
throw 'Analytics is not initialized.'; throw 'Analytics is not initialized.';
_gaq.push(['_trackEvent', _category, action, label, value]); _gaq.push(['_trackEvent', _category, action, label, value]);
}
} }
} })();
})(); });
\ No newline at end of file
This diff is collapsed.
...@@ -39,44 +39,45 @@ ...@@ -39,44 +39,45 @@
* *
*/ */
(function() { define(
['jquery','underscore','framework7'],
function () {
//Extend jQuery functions
jQuery.fn.extend( {
single: function(types, selector, data, fn) {
return this.off(types, fn).on(types, selector, data, fn);
}
});
//Extend jQuery functions //Extend Dom7 functions
jQuery.fn.extend( { var methods = ['addClass', 'toggleClass', 'removeClass'];
single: function(types, selector, data, fn) {
return this.off(types, fn).on(types, selector, data, fn);
}
});
//Extend Dom7 functions _.each(methods, function (method, index) {
var methods = ['addClass', 'toggleClass', 'removeClass']; var originalMethod = Dom7.fn[method];
_.each(methods, function (method, index) { Dom7.fn[method] = function(className) {
var originalMethod = Dom7.fn[method]; var result = originalMethod.apply(this, arguments);
this.trigger(method, className);
return result;
};
});
Dom7.fn[method] = function(className) { //Extend Underscope functions
var result = originalMethod.apply(this, arguments); _.buffered = function(func, buffer, scope, args) {
this.trigger(method, className); var timerId;
return result;
};
});
//Extend Underscope functions return function() {
_.buffered = function(func, buffer, scope, args) { var callArgs = args || Array.prototype.slice.call(arguments, 0),
var timerId; me = scope || this;
return function() { if (timerId) {
var callArgs = args || Array.prototype.slice.call(arguments, 0), clearTimeout(timerId);
me = scope || this; }
if (timerId) { timerId = setTimeout(function(){
clearTimeout(timerId); func.apply(me, callArgs);
} }, buffer);
};
timerId = setTimeout(function(){
func.apply(me, callArgs);
}, buffer);
}; };
}; }
);
})();
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment