moved module dependencies
This commit is contained in:
parent
9e9e738dbd
commit
bfecf9d525
|
@ -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() {
|
||||||
'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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})();
|
||||||
})();
|
});
|
||||||
|
|
|
@ -30,224 +30,227 @@
|
||||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (Common === undefined) {
|
if (Common === undefined) {
|
||||||
var Common = {};
|
var Common = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.Gateway = new(function() {
|
define(['jquery'], function ($) {
|
||||||
var me = this,
|
Common.Gateway = new(function() {
|
||||||
$me = $(me);
|
var me = this,
|
||||||
|
$me = $(me);
|
||||||
|
|
||||||
var commandMap = {
|
var commandMap = {
|
||||||
'init': function(data) {
|
'init': function(data) {
|
||||||
$me.trigger('init', data);
|
$me.trigger('init', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'openDocument': function(data) {
|
'openDocument': function(data) {
|
||||||
$me.trigger('opendocument', data);
|
$me.trigger('opendocument', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'showMessage': function(data) {
|
'showMessage': function(data) {
|
||||||
$me.trigger('showmessage', data);
|
$me.trigger('showmessage', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'applyEditRights': function(data) {
|
'applyEditRights': function(data) {
|
||||||
$me.trigger('applyeditrights', data);
|
$me.trigger('applyeditrights', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'processSaveResult': function(data) {
|
'processSaveResult': function(data) {
|
||||||
$me.trigger('processsaveresult', data);
|
$me.trigger('processsaveresult', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'processRightsChange': function(data) {
|
'processRightsChange': function(data) {
|
||||||
$me.trigger('processrightschange', data);
|
$me.trigger('processrightschange', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'refreshHistory': function(data) {
|
'refreshHistory': function(data) {
|
||||||
$me.trigger('refreshhistory', data);
|
$me.trigger('refreshhistory', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'setHistoryData': function(data) {
|
'setHistoryData': function(data) {
|
||||||
$me.trigger('sethistorydata', data);
|
$me.trigger('sethistorydata', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'setEmailAddresses': function(data) {
|
'setEmailAddresses': function(data) {
|
||||||
$me.trigger('setemailaddresses', data);
|
$me.trigger('setemailaddresses', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'processMailMerge': function(data) {
|
'processMailMerge': function(data) {
|
||||||
$me.trigger('processmailmerge', data);
|
$me.trigger('processmailmerge', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'downloadAs': function() {
|
'downloadAs': function() {
|
||||||
$me.trigger('downloadas');
|
$me.trigger('downloadas');
|
||||||
},
|
},
|
||||||
|
|
||||||
'processMouse': function(data) {
|
'processMouse': function(data) {
|
||||||
$me.trigger('processmouse', data);
|
$me.trigger('processmouse', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'internalCommand': function(data) {
|
'internalCommand': function(data) {
|
||||||
$me.trigger('internalcommand', data);
|
$me.trigger('internalcommand', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
'resetFocus': function(data) {
|
'resetFocus': function(data) {
|
||||||
$me.trigger('resetfocus', data);
|
$me.trigger('resetfocus', data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var _postMessage = function(msg) {
|
var _postMessage = function(msg) {
|
||||||
// TODO: specify explicit origin
|
// TODO: specify explicit origin
|
||||||
if (window.parent && window.JSON) {
|
if (window.parent && window.JSON) {
|
||||||
window.parent.postMessage(window.JSON.stringify(msg), "*");
|
window.parent.postMessage(window.JSON.stringify(msg), "*");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var _onMessage = function(msg) {
|
var _onMessage = function(msg) {
|
||||||
// TODO: check message origin
|
// TODO: check message origin
|
||||||
var data = msg.data;
|
var data = msg.data;
|
||||||
if (Object.prototype.toString.apply(data) !== '[object String]' || !window.JSON) {
|
if (Object.prototype.toString.apply(data) !== '[object String]' || !window.JSON) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmd, handler;
|
||||||
|
|
||||||
|
try {
|
||||||
|
cmd = window.JSON.parse(data)
|
||||||
|
} catch(e) {
|
||||||
|
cmd = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd) {
|
||||||
|
handler = commandMap[cmd.command];
|
||||||
|
if (handler) {
|
||||||
|
handler.call(this, cmd.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var fn = function(e) { _onMessage(e); };
|
||||||
|
|
||||||
|
if (window.attachEvent) {
|
||||||
|
window.attachEvent('onmessage', fn);
|
||||||
|
} else {
|
||||||
|
window.addEventListener('message', fn, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmd, handler;
|
return {
|
||||||
|
|
||||||
try {
|
ready: function() {
|
||||||
cmd = window.JSON.parse(data)
|
_postMessage({ event: 'onReady' });
|
||||||
} catch(e) {
|
},
|
||||||
cmd = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd) {
|
save: function(url) {
|
||||||
handler = commandMap[cmd.command];
|
_postMessage({
|
||||||
if (handler) {
|
event: 'onSave',
|
||||||
handler.call(this, cmd.data);
|
data: url
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
requestEditRights: function() {
|
||||||
|
_postMessage({ event: 'onRequestEditRights' });
|
||||||
|
},
|
||||||
|
|
||||||
|
requestHistory: function() {
|
||||||
|
_postMessage({ event: 'onRequestHistory' });
|
||||||
|
},
|
||||||
|
|
||||||
|
requestHistoryData: function(revision) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onRequestHistoryData',
|
||||||
|
data: revision
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
requestRestore: function(version, url) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onRequestRestore',
|
||||||
|
data: {
|
||||||
|
version: version,
|
||||||
|
url: url
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
requestEmailAddresses: function() {
|
||||||
|
_postMessage({ event: 'onRequestEmailAddresses' });
|
||||||
|
},
|
||||||
|
|
||||||
|
requestStartMailMerge: function() {
|
||||||
|
_postMessage({event: 'onRequestStartMailMerge'});
|
||||||
|
},
|
||||||
|
|
||||||
|
requestHistoryClose: function(revision) {
|
||||||
|
_postMessage({event: 'onRequestHistoryClose'});
|
||||||
|
},
|
||||||
|
|
||||||
|
reportError: function(code, description) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onError',
|
||||||
|
data: {
|
||||||
|
errorCode: code,
|
||||||
|
errorDescription: description
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
sendInfo: function(info) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onInfo',
|
||||||
|
data: info
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
setDocumentModified: function(modified) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onDocumentStateChange',
|
||||||
|
data: modified
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
internalMessage: function(type, data) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onInternalMessage',
|
||||||
|
data: {
|
||||||
|
type: type,
|
||||||
|
data: data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateVersion: function() {
|
||||||
|
_postMessage({ event: 'onOutdatedVersion' });
|
||||||
|
},
|
||||||
|
|
||||||
|
downloadAs: function(url) {
|
||||||
|
_postMessage({
|
||||||
|
event: 'onDownloadAs',
|
||||||
|
data: url
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
collaborativeChanges: function() {
|
||||||
|
_postMessage({event: 'onCollaborativeChanges'});
|
||||||
|
},
|
||||||
|
|
||||||
|
requestRename: function(title) {
|
||||||
|
_postMessage({event: 'onRequestRename', data: title});
|
||||||
|
},
|
||||||
|
|
||||||
|
metaChange: function(meta) {
|
||||||
|
_postMessage({event: 'onMetaChange', data: meta});
|
||||||
|
},
|
||||||
|
|
||||||
|
on: function(event, handler){
|
||||||
|
var localHandler = function(event, data){
|
||||||
|
handler.call(me, data)
|
||||||
|
};
|
||||||
|
|
||||||
|
$me.on(event, localHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
var fn = function(e) { _onMessage(e); };
|
})();
|
||||||
|
});
|
||||||
if (window.attachEvent) {
|
|
||||||
window.attachEvent('onmessage', fn);
|
|
||||||
} else {
|
|
||||||
window.addEventListener('message', fn, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
ready: function() {
|
|
||||||
_postMessage({ event: 'onReady' });
|
|
||||||
},
|
|
||||||
|
|
||||||
save: function(url) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onSave',
|
|
||||||
data: url
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
requestEditRights: function() {
|
|
||||||
_postMessage({ event: 'onRequestEditRights' });
|
|
||||||
},
|
|
||||||
|
|
||||||
requestHistory: function() {
|
|
||||||
_postMessage({ event: 'onRequestHistory' });
|
|
||||||
},
|
|
||||||
|
|
||||||
requestHistoryData: function(revision) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onRequestHistoryData',
|
|
||||||
data: revision
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
requestRestore: function(version, url) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onRequestRestore',
|
|
||||||
data: {
|
|
||||||
version: version,
|
|
||||||
url: url
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
requestEmailAddresses: function() {
|
|
||||||
_postMessage({ event: 'onRequestEmailAddresses' });
|
|
||||||
},
|
|
||||||
|
|
||||||
requestStartMailMerge: function() {
|
|
||||||
_postMessage({event: 'onRequestStartMailMerge'});
|
|
||||||
},
|
|
||||||
|
|
||||||
requestHistoryClose: function(revision) {
|
|
||||||
_postMessage({event: 'onRequestHistoryClose'});
|
|
||||||
},
|
|
||||||
|
|
||||||
reportError: function(code, description) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onError',
|
|
||||||
data: {
|
|
||||||
errorCode: code,
|
|
||||||
errorDescription: description
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
sendInfo: function(info) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onInfo',
|
|
||||||
data: info
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
setDocumentModified: function(modified) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onDocumentStateChange',
|
|
||||||
data: modified
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
internalMessage: function(type, data) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onInternalMessage',
|
|
||||||
data: {
|
|
||||||
type: type,
|
|
||||||
data: data
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
updateVersion: function() {
|
|
||||||
_postMessage({ event: 'onOutdatedVersion' });
|
|
||||||
},
|
|
||||||
|
|
||||||
downloadAs: function(url) {
|
|
||||||
_postMessage({
|
|
||||||
event: 'onDownloadAs',
|
|
||||||
data: url
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
collaborativeChanges: function() {
|
|
||||||
_postMessage({event: 'onCollaborativeChanges'});
|
|
||||||
},
|
|
||||||
|
|
||||||
requestRename: function(title) {
|
|
||||||
_postMessage({event: 'onRequestRename', data: title});
|
|
||||||
},
|
|
||||||
|
|
||||||
metaChange: function(meta) {
|
|
||||||
_postMessage({event: 'onMetaChange', data: meta});
|
|
||||||
},
|
|
||||||
|
|
||||||
on: function(event, handler){
|
|
||||||
var localHandler = function(event, data){
|
|
||||||
handler.call(me, data)
|
|
||||||
};
|
|
||||||
|
|
||||||
$me.on(event, localHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
|
@ -39,44 +39,45 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
define(
|
||||||
|
['jquery','underscore','framework7'],
|
||||||
//Extend jQuery functions
|
function () {
|
||||||
jQuery.fn.extend( {
|
//Extend jQuery functions
|
||||||
single: function(types, selector, data, fn) {
|
jQuery.fn.extend( {
|
||||||
return this.off(types, fn).on(types, selector, data, fn);
|
single: function(types, selector, data, fn) {
|
||||||
}
|
return this.off(types, fn).on(types, selector, data, fn);
|
||||||
});
|
|
||||||
|
|
||||||
//Extend Dom7 functions
|
|
||||||
var methods = ['addClass', 'toggleClass', 'removeClass'];
|
|
||||||
|
|
||||||
_.each(methods, function (method, index) {
|
|
||||||
var originalMethod = Dom7.fn[method];
|
|
||||||
|
|
||||||
Dom7.fn[method] = function(className) {
|
|
||||||
var result = originalMethod.apply(this, arguments);
|
|
||||||
this.trigger(method, className);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
//Extend Underscope functions
|
|
||||||
_.buffered = function(func, buffer, scope, args) {
|
|
||||||
var timerId;
|
|
||||||
|
|
||||||
return function() {
|
|
||||||
var callArgs = args || Array.prototype.slice.call(arguments, 0),
|
|
||||||
me = scope || this;
|
|
||||||
|
|
||||||
if (timerId) {
|
|
||||||
clearTimeout(timerId);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
timerId = setTimeout(function(){
|
//Extend Dom7 functions
|
||||||
func.apply(me, callArgs);
|
var methods = ['addClass', 'toggleClass', 'removeClass'];
|
||||||
}, buffer);
|
|
||||||
|
_.each(methods, function (method, index) {
|
||||||
|
var originalMethod = Dom7.fn[method];
|
||||||
|
|
||||||
|
Dom7.fn[method] = function(className) {
|
||||||
|
var result = originalMethod.apply(this, arguments);
|
||||||
|
this.trigger(method, className);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
//Extend Underscope functions
|
||||||
|
_.buffered = function(func, buffer, scope, args) {
|
||||||
|
var timerId;
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
var callArgs = args || Array.prototype.slice.call(arguments, 0),
|
||||||
|
me = scope || this;
|
||||||
|
|
||||||
|
if (timerId) {
|
||||||
|
clearTimeout(timerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
timerId = setTimeout(function(){
|
||||||
|
func.apply(me, callArgs);
|
||||||
|
}, buffer);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
);
|
||||||
})();
|
|
||||||
|
|
Loading…
Reference in a new issue