Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

third commit

  • Loading branch information...
commit c27fb408d66dd6e06fbd7f1283439433dc6821ac 1 parent 7faf6bb
@diverso authored
View
46 Parts/Button.js
@@ -0,0 +1,46 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+function CreateButton(elementOrID, spec)
+{
+ var buttonElement = elementOrID;
+ if (elementOrID.nodeType != Node.ELEMENT_NODE) {
+ buttonElement = document.getElementById(elementOrID);
+ }
+
+ if (!buttonElement.loaded) {
+ buttonElement.loaded = true;
+ while (buttonElement.firstChild) {
+ buttonElement.removeChild(buttonElement.firstChild);
+ }
+
+ var text = spec.text || '';
+ if (window.dashcode && dashcode.getLocalizedString) text = dashcode.getLocalizedString(text);
+
+ var leftImageWidth = spec.leftImageWidth || 0;
+ var rightImageWidth = spec.rightImageWidth || 0;
+ // when cloning template, get size from original
+ var styleElement = buttonElement;
+ if (spec.originalID) {
+ styleElement = document.getElementById(spec.originalID);
+ }
+ var imagePrefix = "Images/" + styleElement.id + "_";
+ var width = dashcode.getElementWidth(styleElement) || 20;
+ var height = dashcode.getElementHeight(styleElement) || 20;
+
+ var onclick = spec.onclick || null;
+ try { onclick = eval(onclick); } catch (e) { onclick = null; }
+
+ buttonElement.object = new AppleButton(buttonElement, text, height, imagePrefix + "left.png", imagePrefix + "left_clicked.png", leftImageWidth, imagePrefix + "middle.png", imagePrefix + "middle_clicked.png", imagePrefix + "right.png", imagePrefix + "right_clicked.png", rightImageWidth, onclick);
+ buttonElement.object.element = buttonElement;
+ buttonElement.object._container.childNodes.item(2).style.width = rightImageWidth + "px";
+ buttonElement.object.setEnabled(!spec.disabled);
+ buttonElement.object.textElement.style.width = (width - (leftImageWidth + rightImageWidth)) + "px";
+ }
+
+ return buttonElement.object;
+}
View
33 Parts/GlassButton.js
@@ -0,0 +1,33 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+function CreateGlassButton(elementOrID, spec)
+{
+ var buttonElement = elementOrID;
+ if (elementOrID.nodeType != Node.ELEMENT_NODE) {
+ buttonElement = document.getElementById(elementOrID);
+ }
+
+ if (!buttonElement.loaded) {
+ buttonElement.loaded = true;
+ while (buttonElement.firstChild) {
+ buttonElement.removeChild(buttonElement.firstChild);
+ }
+
+ var text = spec.text || '';
+ if (window.dashcode && dashcode.getLocalizedString) text = dashcode.getLocalizedString(text);
+
+ var onclick = spec.onclick || null;
+ try { onclick = eval(onclick); } catch (e) { onclick = null; }
+
+ buttonElement.object = new AppleGlassButton(buttonElement, text, onclick);
+ buttonElement.object.element = buttonElement;
+ buttonElement.object.setEnabled(!spec.disabled);
+ }
+
+ return buttonElement.object;
+}
View
28 Parts/InfoButton.js
@@ -0,0 +1,28 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+function CreateInfoButton(elementOrID, spec)
+{
+ var flipElement = elementOrID;
+ if (elementOrID.nodeType != Node.ELEMENT_NODE) {
+ flipElement = document.getElementById(elementOrID);
+ }
+ if (!flipElement.loaded) {
+ flipElement.loaded = true;
+ while (flipElement.firstChild) {
+ flipElement.removeChild(flipElement.firstChild);
+ }
+
+ var onclick = spec.onclick || null;
+ try { onclick = eval(onclick); } catch (e) { onclick = null; }
+
+ flipElement.object = new AppleInfoButton(flipElement, document.getElementById(spec.frontID), spec.foregroundStyle, spec.backgroundStyle, onclick);
+ flipElement.object.element = flipElement;
+ }
+
+ return flipElement.object;
+}
View
141 Parts/ScrollArea.js
@@ -0,0 +1,141 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+function CreateScrollArea(elementOrID, spec)
+{
+ var scrollAreaElement = elementOrID;
+ if (elementOrID.nodeType != Node.ELEMENT_NODE) {
+ scrollAreaElement = document.getElementById(elementOrID);
+ }
+
+ if (!scrollAreaElement.loaded) {
+ var element = null;
+ var style = null;
+ var contentElement = null;
+ var verticalScrollbar = null;
+ var horizontalScrollbar = null;
+ var hasVerticalScrollbar = spec.hasVerticalScrollbar == undefined ? false : spec.hasVerticalScrollbar;
+ var hasHorizontalScrollbar = spec.hasHorizontalScrollbar == undefined ? false : spec.hasHorizontalScrollbar;
+ var autoHideScrollbars = spec.autoHideScrollbars == undefined ? false : spec.autoHideScrollbars;
+ var leftMargin = spec.leftMargin == undefined ? 0 : spec.leftMargin;
+ var rightMargin = spec.rightMargin == undefined ? 0 : spec.rightMargin;
+ var topMargin = spec.topMargin == undefined ? 0 : spec.topMargin;
+ var bottomMargin = spec.bottomMargin == undefined ? 0 : spec.bottomMargin;
+ var scrollbarMargin = spec.scrollbarMargin == undefined ? 0 : spec.scrollbarMargin;;
+ var leftScrollbarMargin = leftMargin + scrollbarMargin;
+ var rightScrollbarMargin = rightMargin + scrollbarMargin;
+ var topScrollbarMargin = topMargin + scrollbarMargin;
+ var bottomScrollbarMargin = bottomMargin + scrollbarMargin;
+ var spacing = spec.spacing == undefined ? 0 : spec.spacing;
+ var scrollbarSize = spec.scrollbarDivSize == undefined ? 0 : spec.scrollbarDivSize;;
+
+ // Associate or create the content area element
+ var childIndex;
+ for (childIndex=0; childIndex<scrollAreaElement.childNodes.length; childIndex++) {
+ var child = scrollAreaElement.childNodes[childIndex];
+ if (child.nodeType == Node.ELEMENT_NODE) {
+ contentElement = child;
+ break;
+ }
+ }
+ // Remove all other child elements
+ while (scrollAreaElement.childNodes.length > childIndex+1) {
+ scrollAreaElement.removeChild(scrollAreaElement.lastChild);
+ }
+ if (contentElement == null || contentElement == undefined) {
+ contentElement = document.createElement("div");
+ }
+
+ style = contentElement.style;
+ style.position = "absolute";
+ style.left = leftMargin + "px";
+ style.top = topMargin + "px";
+
+ if (hasVerticalScrollbar && hasHorizontalScrollbar) {
+ style.right = rightMargin + scrollbarSize + spacing + "px";
+ style.bottom = bottomMargin + scrollbarSize + spacing + "px";
+ } else if (hasVerticalScrollbar) {
+ style.right = rightMargin + scrollbarSize + spacing + "px";
+ style.bottom = bottomMargin + "px";
+ } else if (hasHorizontalScrollbar) {
+ style.right = rightMargin + "px";
+ style.bottom = bottomMargin + scrollbarSize + spacing + "px";
+ } else {
+ style.right = rightMargin + "px";
+ style.bottom = bottomMargin + "px";
+ }
+ scrollAreaElement.appendChild(contentElement);
+ scrollAreaElement.contentElement = contentElement;
+ scrollAreaElement.content = contentElement;
+
+ // Create the vertical scroll bar
+ if (hasVerticalScrollbar) {
+ element = document.createElement("div");
+ element.className = "apple-no-children apple-remove";
+ style = element.style;
+ style.position = "absolute";
+ style.width = scrollbarSize + "px";
+ style.height = "auto";
+ style.right = rightMargin + "px";
+ style.top = topScrollbarMargin + "px";
+ style.bottom = hasHorizontalScrollbar ? bottomScrollbarMargin + scrollbarSize + "px" : bottomScrollbarMargin + "px";
+ style.appleDashboardRegion = "none";
+ scrollAreaElement.appendChild(element);
+ verticalScrollbar = new AppleVerticalScrollbar(element);
+ scrollAreaElement.verticalScrollbarElement = element;
+ }
+
+ // Create the horizontal scroll bar
+ if (hasHorizontalScrollbar) {
+ element = document.createElement("div");
+ element.className = "apple-no-children apple-remove";
+ style = element.style;
+ style.position = "absolute";
+ style.width = "auto";
+ style.height = scrollbarSize + "px";
+ style.left = leftScrollbarMargin + "px";
+ style.right = hasVerticalScrollbar ? rightScrollbarMargin + scrollbarSize + "px" : rightScrollbarMargin + "px";
+ style.bottom = bottomMargin + "px";
+ style.appleDashboardRegion = "none";
+ scrollAreaElement.appendChild(element);
+ horizontalScrollbar = new AppleHorizontalScrollbar(element);
+ scrollAreaElement.horizontalScrollbarElement = element;
+ }
+
+ // Create the scroll area
+ if (hasVerticalScrollbar && hasHorizontalScrollbar) {
+ scrollAreaElement.object = new AppleScrollArea(contentElement, verticalScrollbar, horizontalScrollbar);
+ } else if (hasVerticalScrollbar) {
+ scrollAreaElement.object = new AppleScrollArea(contentElement, verticalScrollbar);
+ } else if (hasHorizontalScrollbar) {
+ scrollAreaElement.object = new AppleScrollArea(contentElement, horizontalScrollbar);
+ } else {
+ scrollAreaElement.object = new AppleScrollArea(contentElement);
+ }
+ scrollAreaElement.object.element = scrollAreaElement;
+
+ // Adjust the auto hide setting
+ if (verticalScrollbar) {
+ verticalScrollbar.setAutohide(autoHideScrollbars);
+ }
+ if (horizontalScrollbar) {
+ horizontalScrollbar.setAutohide(autoHideScrollbars);
+ }
+
+ scrollAreaElement.object.contentElement = contentElement;
+ scrollAreaElement.object.content = contentElement;
+ if (spec.originalID) {
+ // when cloning template, refresh shortly after initialized
+ var self = scrollAreaElement;
+ window.setTimeout(function() {self.object.refresh();}, 0);
+ } else {
+ scrollAreaElement.object.refresh();
+ }
+ }
+
+ return scrollAreaElement.object;
+}
View
126 Parts/Shape.js
@@ -0,0 +1,126 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+// Note: Properties and methods beginning with underbar ("_") are considered private and subject to change in future Dashcode releases.
+
+function CreateShape(elementOrID, spec)
+{
+ var shapeElement = elementOrID;
+ if (elementOrID.nodeType != Node.ELEMENT_NODE) {
+ shapeElement = document.getElementById(elementOrID);
+ }
+ if (!shapeElement.loaded) {
+ shapeElement.loaded = true;
+ // when cloning template, get size from original
+ var styleElement = shapeElement;
+ if (spec.originalID) {
+ styleElement = document.getElementById(spec.originalID);
+ }
+ var prefix = "Images/" + styleElement.id + "_";
+ var height = dashcode.getElementHeight(styleElement) || 20;
+ var leftImageWidth = spec.leftImageWidth || 0;
+ var rightImageWidth = spec.rightImageWidth || 0;
+ shapeElement.object = new Shape(shapeElement, height, leftImageWidth, rightImageWidth, prefix + "left.png", prefix + "middle.png", prefix + "right.png");
+
+ return shapeElement.object;
+ }
+}
+
+function Shape(shape, height, leftImageWidth, rightImageWidth, imgLeft, imgMiddle, imgRight)
+{
+ this._init(shape, height, leftImageWidth, rightImageWidth, imgLeft, imgMiddle, imgRight);
+}
+
+Shape.prototype.remove = function()
+{
+ var parent = this._container.parentNode;
+ parent.removeChild(this._container);
+}
+
+Shape.prototype._init = function(shape, height, leftImageWidth, rightImageWidth, imgLeft, imgMiddle, imgRight)
+{
+ if (shape) {
+ this.element = shape;
+ this._imgLeftPath = imgLeft;
+ this._imgMiddlePath = imgMiddle;
+ this._imgRightPath = imgRight;
+
+ var style = null;
+ var element = null;
+
+ while (shape.firstChild) {
+ shape.removeChild(shape.firstChild);
+ }
+ var container = document.createElement("div");
+ this._container = container;
+
+ shape.appendChild(container);
+
+ // Create the inner elements
+ var element = document.createElement("div");
+ var style = element.style;
+ style.position = "absolute";
+ style.display = "inline-block";
+ style.background = "url(" + this._imgLeftPath + ") no-repeat top left";
+ style.height = height + "px";
+ style.width = leftImageWidth + "px";
+ container.appendChild(element);
+
+ element = document.createElement("div");
+ style = element.style;
+ style.position = "absolute";
+ style.display = "inline-block";
+ style.backgroundRepeat = "repeat-x";
+ style.backgroundImage = "url(" + this._imgMiddlePath + ")";
+ style.lineHeight = height + "px";
+ style.height = height + "px";
+ style.left = leftImageWidth + "px";
+ style.right = rightImageWidth + "px";
+ style.overflow = "hidden";
+ style.width = "auto";
+ style.whiteSpace = "nowrap";
+ container.appendChild(element);
+
+ element = document.createElement("div");
+ style = element.style;
+ style.position = "absolute";
+ style.display = "inline-block";
+ style.background = "url(" + this._imgRightPath + ") no-repeat top left";
+ style.height = height + "px";
+ style.width = rightImageWidth + "px";
+ style.right = 0 + "px";
+ container.appendChild(element);
+
+ style = container.style;
+ style.left = 0;
+ style.right = 0;
+ style.width = "auto";
+ style.height = height + "px";
+ }
+}
+
+Shape.prototype._updateImages = function(height, leftImageWidth, rightImageWidth)
+{
+ this._container.style.height = height + "px";
+
+ var leftDiv = this._container.children[0];
+ leftDiv.style.background = "url(" + this._imgLeftPath + ") no-repeat top left";
+ leftDiv.style.height = height + "px";
+ leftDiv.style.width = leftImageWidth + "px";
+
+ var middleDiv = this._container.children[1];
+ middleDiv.style.backgroundImage = "url(" + this._imgMiddlePath + ")";
+ middleDiv.style.height = height + "px";
+ middleDiv.style.left = leftImageWidth + "px";
+ middleDiv.style.right = rightImageWidth + "px";
+
+ var rightDiv = this._container.children[2];
+ rightDiv.style.background = "url(" + this._imgRightPath + ") no-repeat top left";
+ rightDiv.style.height = height + "px";
+ rightDiv.style.width = rightImageWidth + "px";
+ rightDiv.style.right = 0 + "px";
+}
View
18 Parts/Text.js
@@ -0,0 +1,18 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+function CreateText(elementOrID, spec)
+{
+ var text = spec.text || '';
+ if (window.dashcode && dashcode.getLocalizedString) text = dashcode.getLocalizedString(text);
+
+ var element = elementOrID;
+ if (elementOrID.nodeType != Node.ELEMENT_NODE) {
+ element = document.getElementById(elementOrID);
+ }
+ element.innerText = text;
+}
View
10 Parts/license.txt
@@ -0,0 +1,10 @@
+
+IMPORTANT: The Apple Software (defined below) supplied to you by Apple Inc. ("Apple") is supplied solely in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of the Apple Software constitutes acceptance of these terms.  If you do not agree with these terms, please do not use, install, modify or redistribute this Apple Software.
+
+Subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in the original Apple software that is generated by Dashcode and not otherwise accompanied by a separate license the ("Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that you are not required to retain this notice and the following text and disclaimers in any redistribution. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple.  Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
+
+The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+EA0439
View
31 Parts/setup.js
@@ -0,0 +1,31 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+var dashcodePartSpecs = {
+ "bottomRectangle": { "creationFunction": "CreateShape", "leftImageWidth": 12, "rightImageWidth": 12 },
+ "descriptionLabel": { "creationFunction": "CreateText", "text": "Description:" },
+ "done": { "creationFunction": "CreateGlassButton", "onclick": "showFront", "text": "Done" },
+ "filtersLabel": { "creationFunction": "CreateText", "text": "Only show markers that contain:" },
+ "fullContentsScroll": { "autoHideScrollbars": true, "creationFunction": "CreateScrollArea", "hasVerticalScrollbar": true, "scrollbarDivSize": 18, "scrollbarMargin": 6, "spacing": 4 },
+ "fullInfoTitle": { "creationFunction": "CreateText" },
+ "fullInfoTitleBg": { "creationFunction": "CreateShape", "leftImageWidth": 1, "rightImageWidth": 1 },
+ "getKeyButton": { "creationFunction": "CreateButton", "leftImageWidth": 5, "onclick": "getMapsKey", "rightImageWidth": 5, "text": "Get a Key" },
+ "hybridButton": { "creationFunction": "CreateButton", "leftImageWidth": 1, "onclick": "setTypeToHybrid", "rightImageWidth": 5, "text": "Hybrid" },
+ "info": { "backgroundStyle": "black", "creationFunction": "CreateInfoButton", "foregroundStyle": "white", "frontID": "front", "onclick": "showBack" },
+ "infoTitle": { "creationFunction": "CreateText" },
+ "infoTitleBg": { "creationFunction": "CreateShape", "leftImageWidth": 12, "rightImageWidth": 12 },
+ "loadingBackground": { "creationFunction": "CreateShape", "leftImageWidth": 5, "rightImageWidth": 5 },
+ "loadingLabel": { "creationFunction": "CreateText", "text": "Loading…" },
+ "mapButton": { "creationFunction": "CreateButton", "leftImageWidth": 5, "onclick": "setTypeToMap", "rightImageWidth": 1, "text": "Map" },
+ "messagesLabel": { "creationFunction": "CreateText" },
+ "readMore": { "creationFunction": "CreateText", "text": "Read more…" },
+ "satelliteButton": { "creationFunction": "CreateButton", "leftImageWidth": 1, "onclick": "setTypeToSatellite", "rightImageWidth": 1, "text": "Satellite" },
+ "title": { "creationFunction": "CreateText", "text": "Map title shows here " },
+ "titleLabel": { "creationFunction": "CreateText", "text": "Title:" },
+ "topRectangle": { "creationFunction": "CreateShape", "leftImageWidth": 12, "rightImageWidth": 12 },
+ "zoomInButton": { "creationFunction": "CreateButton", "leftImageWidth": 1, "onclick": "zoomIn", "rightImageWidth": 5 },
+ "zoomOutButton": { "creationFunction": "CreateButton", "leftImageWidth": 5, "onclick": "zoomOut", "rightImageWidth": 1 }
+};
View
263 Parts/utilities.js
@@ -0,0 +1,263 @@
+/*
+ This file was generated by Dashcode and is covered by the
+ license.txt included in the project. You may edit this file,
+ however it is recommended to first turn off the Dashcode
+ code generator otherwise the changes will be lost.
+ */
+
+if (!window.dashcode) {
+ dashcode = new Object();
+}
+
+//
+// setupParts(string)
+// Uses the dashcodePartsSpec dictionary, declared in the automatically generated file setup.js to instantiate
+// all the parts in the project.
+//
+dashcode.setupParts = function () {
+ if (dashcode.setupParts.called) return;
+ dashcode.setupParts.called = true;
+ var partsToGetFinishLoading = [];
+ for (var id in dashcodePartSpecs) {
+ var specDict = dashcodePartSpecs[id];
+ var createFunc = window[specDict.creationFunction];
+ var object = createFunc(id, specDict);
+ if (object && object.finishLoading) {
+ partsToGetFinishLoading[partsToGetFinishLoading.length] = object;
+ }
+ }
+ // Call finishedLoading callbacks.
+ for (var i=0; i<partsToGetFinishLoading.length; i++) {
+ partsToGetFinishLoading[i].finishLoading();
+ }
+}
+window.addEventListener('load', dashcode.setupParts, false);
+
+//
+// getLocalizedString(string)
+// Pulls a string out an array named localizedStrings. Each language project directory in this widget
+// contains a file named "localizedStrings.js", which, in turn, contains an array called localizedStrings.
+// This method queries the array of the file of whichever language has highest precedence, according to
+// your preference set in the language toolbar item
+//
+// string: the key to the array
+//
+dashcode.getLocalizedString = function (string) {
+ try { string = localizedStrings[string] || string; } catch (e) {}
+ return string;
+}
+
+//
+// createInstancePreferenceKey(key)
+// Returns a unique preference key that is based on a instance of an opened widget.
+// The returned value can then be used in widget.setPreferenceForKey()
+// and widget.preferenceForKey() so that the value that is set or retrieved is
+// only for a particular opened widget.
+//
+// key: preference key
+//
+dashcode.createInstancePreferenceKey = function (key) {
+ return widget.identifier + "-" + key;
+}
+
+//
+// getElementHeight(mainElement)
+// Get the height of a part even if it's hidden (by 'display: none').
+//
+// mainElement: Part element
+//
+dashcode.getElementHeight = function (mainElement) {
+ var height = mainElement.offsetHeight;
+
+ if (!height || height == 0) {
+ height = dashcode.getElementSize(mainElement).height;
+ }
+
+ return height;
+}
+
+//
+// getElementWidth(mainElement)
+// Get the width of a part even if it's hidden (by 'display: none').
+//
+// mainElement: Part element
+//
+dashcode.getElementWidth = function (mainElement) {
+ var width = mainElement.offsetWidth;
+
+ if (!width || width == 0) {
+ width = dashcode.getElementSize(mainElement).width;
+ }
+
+ return width;
+}
+
+//
+// getElementSize(mainElement)
+// Get the size of a DOM element even if it's hidden (by 'display: none').
+//
+// mainElement: DOM element
+//
+dashcode.getElementSize = function (mainElement) {
+ var sizes = dashcode.getElementSizesWithAncestor([mainElement], mainElement);
+ return sizes[0];
+}
+
+//
+// getElementSizesWithAncestor(elements, ancestor)
+// Get the size of an array of DOM elements under a common ancestor even if they're hidden (by 'display: none').
+//
+// elements: Array of DOM element
+// ancestor: Common DOM ancestor. 'display' will temporarily be flipped to 'block' for all hidden ancestors of this element.
+//
+dashcode.getElementSizesWithAncestor = function (elements, ancestor) {
+ if (elements.length < 1) return [];
+
+ var displayNoneElements = new Array();
+ var width = elements[0].offsetWidth;
+
+ if (!width || width == 0) {
+ var parentNode = ancestor;
+ while (parentNode && (parentNode != document)) {
+ var style = document.defaultView.getComputedStyle(parentNode, null);
+ var displayValue = style ? style.getPropertyValue("display") : parentNode.style.display;
+ if ((style && displayValue == "none") || (!style && displayValue != "block")) {
+ displayNoneElements.push({node:parentNode, display:parentNode.style.display});
+ parentNode.style.display = "block";
+ }
+ parentNode = parentNode.parentNode;
+ }
+ }
+
+ var sizes = new Array();
+ for (var i=0; i<elements.length; i++) {
+ sizes.push({width: elements[i].offsetWidth, height: elements[i].offsetHeight});
+ }
+
+ for (var i=0; i<displayNoneElements.length; i++) {
+ var element = displayNoneElements[i].node;
+ element.style.display = displayNoneElements[i].display;
+ // clean up
+ if (element.getAttribute("style") == "") {
+ element.removeAttribute("style");
+ }
+ }
+
+ return sizes;
+}
+
+dashcode.getElementDocumentOffset = function(element)
+{
+ var parent = element.offsetParent;
+ var offset = {x:element.offsetLeft,y:element.offsetTop};
+
+ if( parent ){
+ var parentOffset = dashcode.getElementDocumentOffset(parent);
+
+ offset.x += parentOffset.x;
+ offset.y += parentOffset.y;
+ }
+
+ return offset;
+}
+
+dashcode.pointInElement = function (x,y,element)
+{
+ var size = dashcode.getElementSize(element);
+ var origin = dashcode.getElementDocumentOffset(element);
+
+ // Check horizontally
+ if( x >= origin.x ){
+ if( x > origin.x + size.width )
+ return false;
+
+ if( y >= origin.y ){
+ if( y > origin.y + size.height )
+ return false;
+ }else
+ return false;
+ }else
+ return false;
+
+ return true;
+}
+
+//
+// cloneTemplateElement(element, isTemplate)
+// Clone an element and initialize the parts it contains. The new element is simply returned and not added to the DOM.
+//
+// element: element to clone
+// isTemplate: true if this is the template element
+//
+dashcode.cloneTemplateElement = function (element, isTemplate) {
+ // clone the node and its subtree
+ var newElement = isTemplate ? element : element.cloneNode(true);
+ var templateElements = new Object();
+ this.processClonedTemplateElement(newElement, templateElements, isTemplate);
+
+ if( !newElement.object ) newElement.object = {};
+
+ newElement.object.templateElements = templateElements;
+
+ // finish loading parts that need post-processing
+ for (var key in templateElements) {
+ if (templateElements[key].object && templateElements[key].object.finishLoading) {
+ templateElements[key].object.finishLoading();
+ }
+ }
+
+ return newElement;
+}
+
+//
+// processClonedTemplateElement(element, templateElements, isTemplate, preserveIds)
+// Recursively process a newly cloned template element to remove IDs and initialize parts.
+//
+// element: element to process
+// templateElements: list of references to template objects to populate
+// isTemplate: true if this is the template element
+// preserveIds: true to preserve the original id in a tempId attribute
+//
+dashcode.processClonedTemplateElement = function (element, templateElements, isTemplate, preserveIds) {
+ var originalID = element.id;
+ if (!originalID && element.getAttribute) {
+ if (originalID = element.getAttribute("tempId")) {
+ element.removeAttribute("tempId");
+ }
+ }
+ var partSpec = null;
+ if (originalID) {
+ partSpec = dashcodePartSpecs[originalID];
+ }
+ // process the children first
+ var preserveChildIds = preserveIds || (partSpec && partSpec.preserveChildIdsWhenCloning);
+ var children = element.childNodes;
+ for (var f=0; f<children.length; f++) {
+ arguments.callee(children[f], templateElements, isTemplate, preserveChildIds);
+ }
+ if (originalID) {
+ templateElements[originalID] = element;
+ if (!isTemplate) {
+ element.removeAttribute("id");
+ if (preserveIds) {
+ element.setAttribute("tempId", originalID);
+ }
+ // if it's a 'part', initialize it
+ if (partSpec) {
+ partSpec.originalID = originalID;
+ var createFunc = window[partSpec.creationFunction];
+ if (createFunc && createFunc instanceof Function) {
+ createFunc(element, partSpec);
+ }
+ }
+ }
+ }
+}
+
+// Old function names for backwards compatibility
+var setupParts = dashcode.setupParts;
+var getLocalizedString = dashcode.getLocalizedString;
+var createInstancePreferenceKey = dashcode.createInstancePreferenceKey;
+var getElementHeight = dashcode.getElementHeight;
+var getElementWidth = dashcode.getElementWidth;
+var getElementSize = dashcode.getElementSize;
Please sign in to comment.
Something went wrong with that request. Please try again.