Skip to content

Commit

Permalink
Merge branch 'release/8.33.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
it-ony committed Mar 12, 2015
2 parents 62a1568 + aec2aff commit c52e11e
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 32 deletions.
2 changes: 2 additions & 0 deletions sprd/data/ImageService.js
Expand Up @@ -111,6 +111,8 @@ define(['js/core/Component', 'underscore'], function (Component, _) {

ImageService.getImageSizeParameter = function (options) {

options = options || {};

var ret = {};

if (options.width) {
Expand Down
10 changes: 9 additions & 1 deletion sprd/entity/Appearance.js
@@ -1,9 +1,17 @@
define(['sprd/entity/AppearanceBase', 'sprd/model/PrintType', 'sprd/entity/AppearanceColor'], function (Entity, PrintType, AppearanceColor) {
return Entity.inherit('sprd.entity.Appearance', {

defaults: {
texture: false,
brightness: 100
},

schema: {
name: String,
printTypes: [PrintType],
colors: [AppearanceColor]
colors: [AppearanceColor],
texture: Boolean,
brightness: Number
}
})
});
12 changes: 10 additions & 2 deletions sprd/entity/TextConfiguration.js
Expand Up @@ -231,7 +231,9 @@ define(['sprd/entity/Configuration', "flow", 'sprd/entity/Size', 'underscore', '
return;
}

var textFlow = this.$.textFlow;
var textFlow = this.$.textFlow,
printColors = [],
printColor;
if (textFlow) {

var useThisColor = null;
Expand All @@ -248,10 +250,16 @@ define(['sprd/entity/Configuration', "flow", 'sprd/entity/Size', 'underscore', '
useThisColor = printType.getClosestPrintColor(printTypeColor.color());
}

style.set('printTypeColor', useThisColor || printType.getClosestPrintColor(printTypeColor.color()));
printColor = useThisColor || printType.getClosestPrintColor(printTypeColor.color());
if(!printColors.length){
printColors = [printColor];
}

style.set('printTypeColor', printColor);
}
} while ((leaf = leaf.getNextLeaf(textFlow)));

this.$.printColors.reset(printColors);
this._composeText();
}

Expand Down
96 changes: 73 additions & 23 deletions sprd/lib/raygun.js
@@ -1,4 +1,4 @@
/*! Raygun4js - v1.8.3 - 2014-05-08
/*! Raygun4js - v1.8.1 - 2014-04-15
* https://github.com/MindscapeHQ/raygun4js
* Copyright (c) 2014 MindscapeHQ; Licensed MIT */
;(function(window, undefined) {
Expand Down Expand Up @@ -1100,6 +1100,67 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
_helper('setInterval');
}());

/**
* Extended support for backtraces and global error handling for most
* asynchronous jQuery functions.
*/
(function traceKitAsyncForjQuery($) {

// quit if jQuery isn't on the page
if (!$) {
return;
}

var _oldEventAdd = $.event.add;
$.event.add = function traceKitEventAdd(elem, types, handler, data, selector) {
var _handler;

if (handler.handler) {
_handler = handler.handler;
handler.handler = TraceKit.wrap(handler.handler);
} else {
_handler = handler;
handler = TraceKit.wrap(handler);
}

// If the handler we are attaching doesn’t have the same guid as
// the original, it will never be removed when someone tries to
// unbind the original function later. Technically as a result of
// this our guids are no longer globally unique, but whatever, that
// never hurt anybody RIGHT?!
if (_handler.guid) {
handler.guid = _handler.guid;
} else {
handler.guid = _handler.guid = $.guid++;
}

return _oldEventAdd.call(this, elem, types, handler, data, selector);
};

var _oldReady = $.fn.ready;
$.fn.ready = function traceKitjQueryReadyWrapper(fn) {
return _oldReady.call(this, TraceKit.wrap(fn));
};

var _oldAjax = $.ajax;
$.ajax = function traceKitAjaxWrapper(s) {
var keys = ['complete', 'error', 'success'], key;
while(key = keys.pop()) {
if ($.isFunction(s[key])) {
s[key] = TraceKit.wrap(s[key]);
}
}

try {
return _oldAjax.call(this, s);
} catch (e) {
TraceKit.report(e);
throw e;
}
};

}(window.jQuery));

//Default options:
if (!TraceKit.remoteFetching) {
TraceKit.remoteFetching = true;
Expand Down Expand Up @@ -1259,9 +1320,7 @@ window.TraceKit = TraceKit;
send: function (ex, customData, tags) {
try {
processUnhandledException(_traceKit.computeStackTrace(ex), {
customData: typeof _customData === 'function' ?
merge(_customData(), customData) :
merge(_customData, customData),
customData: merge(_customData, customData),
tags: mergeArray(_tags, tags)
});
}
Expand Down Expand Up @@ -1298,21 +1357,16 @@ window.TraceKit = TraceKit;
// truncate after fourth /, or 24 characters, whichever is shorter
// /api/1/diagrams/xyz/server becomes
// /api/1/diagrams/...
var truncated = url;
var path = url.split('//')[1];

if (path) {
var queryStart = path.indexOf('?');
var sanitizedPath = path.toString().substring(0, queryStart);
var truncated_parts = sanitizedPath.split('/').slice(0, 4).join('/');
var truncated_length = sanitizedPath.substring(0, 48);
truncated = truncated_parts.length < truncated_length.length?
truncated_parts : truncated_length;
if (truncated !== sanitizedPath) {
truncated += '..';
}
var queryStart = path.indexOf('?');
var sanitizedPath = path.toString().substring(0, queryStart);
var truncated_parts = sanitizedPath.split('/').slice(0, 4).join('/');
var truncated_length = sanitizedPath.substring(0, 48);
var truncated = truncated_parts.length < truncated_length.length?
truncated_parts : truncated_length;
if (truncated !== sanitizedPath) {
truncated += '..';
}

return truncated;
}

Expand Down Expand Up @@ -1444,11 +1498,7 @@ window.TraceKit = TraceKit;
}

if (isEmpty(options.customData)) {
if (typeof _customData === 'function') {
options.customData = _customData();
} else {
options.customData = _customData;
}
options.customData = _customData;
}

if (isEmpty(options.tags)) {
Expand Down Expand Up @@ -1482,7 +1532,7 @@ window.TraceKit = TraceKit;
},
'Client': {
'Name': 'raygun-js',
'Version': '1.8.3'
'Version': '1.8.1'
},
'UserCustomData': options.customData,
'Tags': options.tags,
Expand Down
5 changes: 4 additions & 1 deletion sprd/model/DesignCategory.js
@@ -1,9 +1,12 @@
define(["sprd/data/SprdModel", "sprd/model/Design", "js/data/Collection"], function (Model, Design, Collection) {
define(["sprd/data/SprdModel", "sprd/model/Design", "js/data/Collection", "js/core/List"], function (Model, Design, Collection, List) {

var DesignCategory = Model.inherit('sprd.model.DesignCategory', {
schema: {
designs: Collection.of(Design)
},
defaults: {
designCategories: List
},

isMarketPlace: function () {
return this.$.type === "MARKETPLACE";
Expand Down
5 changes: 4 additions & 1 deletion sprd/view/AppearanceColor.xml
@@ -1,7 +1,10 @@
<view:AppearanceColorClass xmlns:view="sprd.view" xmlns:js="js.core" xmlns:ui="js.ui" xmlns='http://www.w3.org/1999/xhtml'>
<ui:ItemsView items="{appearance.colors}" itemKey="$color">
<ui:ItemsView items="{appearance.colors}" itemKey="$color" visible="{not(appearance.texture)}">
<js:Template name="item">
<div backgroundColor="${$color.color().toString()}" width="${colorWidth(index)}%"/>
</js:Template>
</ui:ItemsView>
<div visible="{appearance.texture}">
<div backgroundImage="url({textureImage()})" width="100%"/>
</div>
</view:AppearanceColorClass>
21 changes: 19 additions & 2 deletions sprd/view/AppearanceColorClass.js
@@ -1,4 +1,4 @@
define(["js/ui/View"], function (View) {
define(["js/ui/View", "sprd/data/ImageService"], function (View, ImageService) {

var ratios = {
2: [75, 25],
Expand All @@ -15,6 +15,10 @@ define(["js/ui/View"], function (View) {
title: "{appearance.name}"
},

inject: {
imageService: ImageService
},

colorWidth: function (index) {
var length = this.get("appearance.colors.length");

Expand All @@ -38,7 +42,20 @@ define(["js/ui/View"], function (View) {

return ret;

}.onChange("appearance")
}.onChange("appearance"),

textureImage: function() {

var imageService = this.$.imageService,
appearance = this.$.appearance;

if (!(imageService && appearance && appearance.$.texture)) {
return;
}

return imageService.appearanceImage(appearance.$.id);

}.onChange("apperance")

});

Expand Down
44 changes: 42 additions & 2 deletions sprd/view/svg/ProductTypeViewViewer.js
Expand Up @@ -27,10 +27,13 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi

productViewer: null,

dropHovered: false,

_width: "{productViewer.width}",
_height: "{productViewer.height}",
_appearance: "{product.appearance}",


_view: null,
_productType: null,

Expand Down Expand Up @@ -68,6 +71,10 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi

},

checkForDropHover: function (x, y) {
this.set('dropHovered', this.isPointInElement(x, y));
},

_initializeRenderer: function () {

var width = this.get("_view.size.width");
Expand Down Expand Up @@ -114,6 +121,7 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi
},

bindMoveEvent: function () {
var self = this;
if (!this.$moveHandler) {
this.$moveHandler = function (e) {
if (dndObject) {
Expand All @@ -124,6 +132,14 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi
y = pointerEvent.clientY;

if (configViewer.$._mode == "move" && !configViewer.$moveInitiator) {
self._debounceFunctionCall(function (x, y) {
for (var i = 0; i < productTypeViewViewer.length; i++) {
if (productTypeViewViewer[i] !== self) {
productTypeViewViewer[i].checkForDropHover(x, y);
}
}
}, "setHoverState", 100, self, [x, y], "BOUNCE");

if (clientRect.left > x || clientRect.right < x || clientRect.top > y || clientRect.bottom < y) {
if (configViewer) {
configViewer.$.configuration.clearErrors();
Expand All @@ -147,12 +163,23 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi
}
}
}
if (!this.$upHandler) {
this.$upHandler = function (e) {
self._handleUp({
domEvent: e
});
};
}
this.dom(this.$stage.$window).bindDomEvent('pointerup', this.$upHandler);
this.dom(this.$stage.$window).bindDomEvent('pointermove', this.$moveHandler);
},
unbindMoveEvent: function () {
if (this.$moveHandler) {
this.dom(this.$stage.$window).unbindDomEvent('pointermove', this.$moveHandler);
}
if (this.$upHandler) {
this.dom(this.$stage.$window).unbindDomEvent('pointerup', this.$upHandler);
}
},
_handleUp: function (e) {
var domEvent = e.domEvent;
Expand All @@ -162,18 +189,19 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi
if (domEvent.changedTouches && domEvent.changedTouches.length) {
viewer = findProductTypeViewViewer(domEvent.changedTouches[0].clientX, domEvent.changedTouches[0].clientY, viewer);
}
var configView = dndObject.configurationViewer;
if (viewer && dndObject.viewer !== viewer) {
e.stopPropagation();
var configView = dndObject.configurationViewer;
configView.set('preventValidation', false);
configView.$moving = false;
viewer.set('dropHovered', false);

var productManager = dndObject.viewer.get('product.manager');
productManager.moveConfigurationToView(dndObject.viewer.$.product, dndObject.config, viewer.$._view, function (err) {
if (!err) {
dndObject.viewer.$.product.set('view', viewer.$._view);
}
});
configView.set('preventValidation', false);
}
dndObject.configurationViewer.removeClass('hide-configuration');
dndObject.dndImage.set({
Expand All @@ -182,6 +210,8 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi
dndObject = null;
}
},


_handleDown: function () {
var productViewer = this.$.productViewer,
selectedConfiguration = productViewer.$.selectedConfiguration;
Expand Down Expand Up @@ -229,6 +259,16 @@ define(['js/svg/SvgElement', "xaml!sprd/view/svg/PrintAreaViewer", "xaml!sprd/vi
}
},

_renderDropHovered: function (hovered) {
if (this.$.productViewer) {
if (hovered) {
this.$.productViewer.addClass('drop-hover');
} else {
this.$.productViewer.removeClass('drop-hover');
}
}
},

getViewerForConfiguration: function (configuration) {
var viewer;
for (var i = 0; i < this.$printAreas.length; i++) {
Expand Down

0 comments on commit c52e11e

Please sign in to comment.